WorldViz User Forum

WorldViz User Forum (https://forum.worldviz.com/index.php)
-   Vizard (https://forum.worldviz.com/forumdisplay.php?f=17)
-   -   Grabbing suparts (https://forum.worldviz.com/showthread.php?t=5960)

mihirradia 02-16-2017 11:09 AM

Grabbing suparts
 
1 Attachment(s)
http://forum.worldviz.com/showthread...light=subparts This to the follow up of this post. I have used the Grabsubparts example script into my code. After I run the code. I'm getting the following error. The error is uploaded in the image.

Below is the gist from my code.
Code:

logoss1 = None
subparts = ['Inst-13015',' Inst-13018', 'Inst-13021', 'Inst-13024',' Inst-12800', 'Inst-12803',' Inst-12806','Inst-11393', 'Inst-11405', 'Inst-11383','Inst-12629 Inst-12619 Inst-12609 Inst-12641 Inst-12631 Inst-12621 Inst-12573 Inst-12599 Inst-12585 Inst-11937 Inst-11931 Inst-11934 Inst-11969 Inst-11972 Inst-11975 Inst-11597 Inst-11594 Inst-11591 Inst-11588 Inst-12261 Inst-12259 Inst-12263 Inst-12265 Inst-12267 Inst-12269 Inst-11960 Inst-11963 Inst-11966 Inst-12277 Inst-12275 Inst-12575 Inst-12587 Inst-12611 Inst-12601 Inst-12694 Inst-12197 Inst-12200 Inst-12692 Inst-12690 Inst-12694 Inst-12696 Inst-12203 Inst-12194']

items = [logoss1]

for subpart in subparts:
        node = logoss1.getChild(subpart)
        pos = node.getPosition(viz.ABS_GLOBAL)
        node.setParent(logoss1)
        node.setPosition(pos,viz.ABS_GLOBAL)
        items.append(node)

grabber = vizconnect.getToolsWithMode('grabber')
grabber.setItems(items)

Please, let me know how do I solve this.

Thanks,
Mihir

Jeff 02-21-2017 10:22 PM

Where are you adding a model and assigning it to the variable name logoss1? In the code posted it's assigned to None.

mihirradia 02-22-2017 08:38 AM

Code:

filePath = vizinput.fileOpen(filter=[('DAE Files','*.dae'),('OSG Files','*.ive;*.osgb;*.osg'),('VRML Files','*.wrl'),('All File','*.*')],directory='3DModels')
logoss1 = None
class ExplosiveModel(viz.VizNode):""" creates a model with a given dae file and gets parts and moves them on specified axes """
global filePath,logoss1,Listchilderen
def __init__(self, rowData):
self.isu = vizfx.addChild(filePath)
logoss1 = self.isu
Listchilderen = logoss1.getNodeNames
viz.VizNode.__init__(self, self.isu.id)
self.scale = .035125 #this scale is determined by doc (dividing model size by .035, we get desired size)
self.isu.setScale([self.scale]*30)
self.current = 0 #index of current
self.rowData = rowData[:]
self.layerParents = []
self.partDict = {}
for tool in vizconnect.getToolsWithMode('Grabber'):
tool.getRaw().setCollisionTester(collision_test.Distance(node=tool.getRaw(), distanceThreshold=1000))
subparts = ['Inst-13015',' Inst-13018', 'Inst-13021', 'Inst-13024',' Inst-12800', 'Inst-12803',' Inst-12806','Inst-11393', 'Inst-11405', 'Inst-11383','Inst-12629 Inst-12619 Inst-12609 Inst-12641 Inst-12631 Inst-12621 Inst-12573 Inst-12599 Inst-12585 Inst-11937 Inst-11931 Inst-11934 Inst-11969 Inst-11972 Inst-11975 Inst-11597 Inst-11594 Inst-11591 Inst-11588 Inst-12261 Inst-12259 Inst-12263 Inst-12265 Inst-12267 Inst-12269 Inst-11960 Inst-11963 Inst-11966 Inst-12277 Inst-12275 Inst-12575 Inst-12587 Inst-12611 Inst-12601 Inst-12694 Inst-12197 Inst-12200 Inst-12692 Inst-12690 Inst-12694 Inst-12696 Inst-12203 Inst-12194']
items = [logoss1]
for subpart in subparts:
node = logoss1.getChild(subpart)
pos = node.getPosition(viz.ABS_GLOBAL)
node.setParent(logoss1)
node.setPosition(pos,viz.ABS_GLOBAL)
items.append(node)
grabber = vizconnect.getToolsWithMode('grabber')
grabber.setItems(items)


mihirradia 02-22-2017 08:40 AM

This is my actual code.

Jeff 02-23-2017 07:07 PM

For help with code issues please follow the guidelines for posting Vizard code.

mihirradia 02-25-2017 12:01 PM

Code:

filePath = vizinput.fileOpen(filter=[('DAE Files','*.dae'),('OSG Files','*.ive;*.osgb;*.osg'),('VRML Files','*.wrl'),('All File','*.*')],directory='3DModels')

logoss1 = None
Listchilderen=[]

GrabedObject=None
ModelsList=[]
ModelsList.append(logoss1)
DissasembeldPart=False
models=None
grabItems=None

class ExplosiveModel(viz.VizNode):
        """ creates a model with a given dae file and gets parts and moves them on specified axes """
        global filePath,logoss1,Listchilderen
        def __init__(self, rowData):
               
                self.isu = vizfx.addChild(filePath)
                logoss1 = self.isu
                Listchilderen = logoss1.getNodeNames
                viz.VizNode.__init__(self, self.isu.id)
                self.scale = .035125 #this scale is determined by doc (dividing model size by .035, we get desired size)
                self.isu.setScale([self.scale]*30)
                self.current = 0 #index of current
                self.rowData = rowData[:]
                self.layerParents = []
                self.partDict = {}
                for tool in vizconnect.getToolsWithMode('Grabber'):
                        tool.getRaw().setCollisionTester(collision_test.Distance(node=tool.getRaw(), distanceThreshold=1000))

subparts = ['Inst-13015',' Inst-13018', 'Inst-13021', 'Inst-13024',' Inst-12800', 'Inst-12803',' Inst-12806','Inst-11393', 'Inst-11405', 'Inst-11383','Inst-12629 Inst-12619 Inst-12609 Inst-12641 Inst-12631 Inst-12621 Inst-12573 Inst-12599 Inst-12585 Inst-11937 Inst-11931 Inst-11934 Inst-11969 Inst-11972 Inst-11975 Inst-11597 Inst-11594 Inst-11591 Inst-11588 Inst-12261 Inst-12259 Inst-12263 Inst-12265 Inst-12267 Inst-12269 Inst-11960 Inst-11963 Inst-11966 Inst-12277 Inst-12275 Inst-12575 Inst-12587 Inst-12611 Inst-12601 Inst-12694 Inst-12197 Inst-12200 Inst-12692 Inst-12690 Inst-12694 Inst-12696 Inst-12203 Inst-12194']

items = [logoss1]

for subpart in subparts:
        node = logoss1.getChild(subpart)
        pos = node.getPosition(viz.ABS_GLOBAL)
        node.setParent(logoss1)
        node.setPosition(pos,viz.ABS_GLOBAL)
        items.append(node)

grabber = vizconnect.getToolsWithMode('grabber')
grabber.setItems(items)


mihirradia 02-25-2017 12:02 PM

I'm sorry for the inconvenience caused.


All times are GMT -7. The time now is 04:54 AM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Copyright 2002-2023 WorldViz LLC