Skip to content

Instantly share code, notes, and snippets.

@Farfarer
Created November 26, 2018 18:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Farfarer/548e6f5089958ec109fda934e6ffe207 to your computer and use it in GitHub Desktop.
Save Farfarer/548e6f5089958ec109fda934e6ffe207 to your computer and use it in GitHub Desktop.
Selects the schematic nodes of the current item selection. Install to <scripts dir>/lxserv and run the command ffr.selectSchmNodes
#!/usr/bin/env python
import lx
import lxu.select
import lxu.command
class SelectSchmNodes_Cmd(lxu.command.BasicCommand):
def __init__(self):
lxu.command.BasicCommand.__init__(self)
self.dyna_Add('distance', lx.symbol.sTYPE_DISTANCE)
self.dyna_Add('item', '&item')
self.basic_SetFlags(1, lx.symbol.fCMDARG_OPTIONAL)
def cmd_UserName(self):
return 'Select Schematic Nodes'
def cmd_Tooltip(self):
return 'Select the schematic nodes for the current item selection.'
def basic_ButtonName(self):
return 'Select Schematic Nodes'
def cmd_Flags(self):
return lx.symbol.fCMD_MODEL | lx.symbol.fCMD_UNDO
def basic_Execute(self, msg, flags):
scene = lxu.select.SceneSelection().current()
graph = lx.object.ItemGraph (scene.GraphLookup ('schmItem'))
sel_svc = lx.service.Selection()
nodeType = sel_svc.LookupType(lx.symbol.sSELTYP_NODE)
itemType = sel_svc.LookupType(lx.symbol.sSELTYP_ITEM)
nodeSelTrans = lx.object.NodePacketTranslation(sel_svc.Allocate(lx.symbol.sSELTYP_NODE))
itemSelTrans = lx.object.ItemPacketTranslation(sel_svc.Allocate(lx.symbol.sSELTYP_ITEM))
sel_svc.StartBatch()
for x in xrange(sel_svc.Count(itemType)):
item = itemSelTrans.Item(sel_svc.ByIndex(itemType, x))
for n in xrange(graph.FwdCount(item)):
sel_svc.Select(nodeType, nodeSelTrans.Packet(graph.FwdByIndex(item, n)))
sel_svc.EndBatch()
lx.bless (SelectSchmNodes_Cmd, 'ffr.selectSchmNodes')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment