<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Selection of bond locations]]></title><description><![CDATA[<p dir="auto">I suggest to implement the possibility to select bonds (without atoms) by location (for instance all bonds centered at z=2 A).  Is it possible ? Thank you very much indeed !</p>
]]></description><link>https://forum.samson-connect.net/topic/89/selection-of-bond-locations</link><generator>RSS for Node</generator><lastBuildDate>Sun, 13 Sep 2026 02:20:29 GMT</lastBuildDate><atom:link href="https://forum.samson-connect.net/topic/89.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 07 Feb 2019 09:25:31 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Selection of bond locations on Thu, 07 Feb 2019 10:46:34 GMT]]></title><description><![CDATA[<p dir="auto">Thank you <a class="plugin-mentions-user plugin-mentions-a" href="/user/cyril" aria-label="Profile: Cyril">@<bdi>Cyril</bdi></a> for the suggestion. We will see whether to add it as a feature in the next version of SAMSON or implement it as a SAMSON Element.</p>
<p dir="auto">For now, you can use <a href="https://samson-connect.net/app/main?key=element&amp;uuid=7b654ce6-e38c-b97f-6746-4fd6934487c2" rel="nofollow ugc">Python Scripting in SAMSON</a>. To use the <a href="https://samson-connect.net/app/main?key=element&amp;uuid=7b654ce6-e38c-b97f-6746-4fd6934487c2" rel="nofollow ugc">Python Scripting SAMSON Element</a> you will need to have a specific version of Python installed. Please, check the <a href="https://documentation.samson-connect.net/scripting-guide/python-script-installation/" rel="nofollow ugc">Python Scripting installation instructions for SAMSON</a>. You can also check the <a href="https://documentation.samson-connect.net/scripting-guide/" rel="nofollow ugc">SAMSON Python Scripting tutorials and documentation</a>.</p>
<p dir="auto">The sample script for this task can be found below. You can either copy it inside of the Python Scripting console in SAMSON, or save it as a <strong>.py</strong> file and open this file in SAMSON when you need to execute this script.</p>
<pre><code>'''
This example shows how to select bonds which center lies in between of two planes: z_min and z_max

If you want to select bonds which center lies on a specific plane, just set z_min=z_max
'''

# Get an indexer of all bonds in the active document. Here we use SAMSON Node Specification Language to get only bonds
allBondsIndexer = SAMSON.getNodes('node.type bond')

# two planes: 1.7A and 2.3A
z_min = Quantity.angstrom(1.7)
z_max = Quantity.angstrom(2.3)

for bond in allBondsIndexer:		# a loop over an indexer
	# compute the z-axis center of the bond 
	bondCenterZ = (bond.leftAtom.getZ() + bond.rightAtom.getZ()) / 2.0
	# check whether the bond lies in between of desired planes
	if bondCenterZ &gt;= z_min and bondCenterZ &lt;= z_max:
		# select the bond by setting the selectionFlag to True
		bond.selectionFlag = True

allBondsIndexer.clear()		# clear an indexer
</code></pre>
]]></description><link>https://forum.samson-connect.net/post/397</link><guid isPermaLink="true">https://forum.samson-connect.net/post/397</guid><dc:creator><![CDATA[DmitriyMarin]]></dc:creator><pubDate>Thu, 07 Feb 2019 10:46:34 GMT</pubDate></item></channel></rss>