![]()  | 
	
| 
		 
			 
			#1  
			
			
			
			
			
		 
		
	 | 
|||
		
		
  | 
|||
| 
		
	
		
		
			
			 
				
				PickRect code snippet
			 
			
			
			Example of window.pickRect that I though could be handy for other folks out in vizland: 
		
		
		
		
		
		
			Code: 
	import viz
import vizact
viz.go()
model = viz.add("mini.osg")
viz.MainView.setPosition([0, 1.2, -5])
viz.mouse.setOverride(viz.ON)
vizact.onkeydown(' ', viz.mouse.setOverride, viz.TOGGLE)
print model.getNodeNames()
parts = []
for name in model.getNodeNames():
    part = model.getChild(name)
    part.nodeName = name
    parts.append(part)
#Rectangle Pick 
viz.startLayer(viz.LINE_LOOP)
viz.vertex([0, 0, 0])
viz.vertex([0, 0, 0])
viz.vertex([0, 0, 0])
viz.vertex([0, 0, 0])
box = viz.endLayer(parent=viz.SCREEN)
box.alpha(.8)
firstPoint = [0,0]
def startPickRect():
    global firstPoint
    firstPoint = viz.mouse.getPosition()
    box.setVertex(0, firstPoint+[0])
vizact.onmousedown(viz.MOUSEBUTTON_LEFT, startPickRect)
def updateBoxVisual():
    if viz.mouse.getState() & viz. MOUSEBUTTON_LEFT:
        mouseScreenPos = viz.mouse.getPosition()
        box.setVertex(1, [mouseScreenPos[0],firstPoint[1],0])
        box.setVertex(2, mouseScreenPos+[0])
        box.setVertex(3, [firstPoint[0],mouseScreenPos[1],0])
vizact.onupdate(viz.PRIORITY_DEFAULT, updateBoxVisual)
def endPickRect():
    mouseScreenPos = viz.mouse.getPosition()
    #update box visual
    box.setVertex(1, [mouseScreenPos[0],firstPoint[1],0])
    box.setVertex(2, mouseScreenPos+[0])
    box.setVertex(3, [firstPoint[0],mouseScreenPos[1],0])
    
    rect = firstPoint + mouseScreenPos    
    # Get all nodes within the rectangle
    picked = viz.MainWindow.pickRect(rect)
    for node in picked:
        print node.nodeName
vizact.onmouseup(viz.MOUSEBUTTON_LEFT, endPickRect)
				__________________ 
		
		
		
		
		
	
	Paul Elliott WorldViz LLC  | 
		
  | 
	
		
  | 
			 
			Similar Threads
		 | 
	||||
| Thread | Thread Starter | Forum | Replies | Last Post | 
| Using Sphinx to generate code documents | nabrahamson | Vizard | 0 | 10-31-2011 08:38 AM | 
| Suggestion: Code Browser | kopper | Vizard | 5 | 05-23-2011 04:39 AM | 
| Any ideas on linking chess 3ds file with source code? | djones1010 | Vizard | 1 | 04-24-2009 10:56 PM | 
| Trying to integrate Source Code with Vizard | djones1010 | Vizard | 1 | 03-10-2009 03:58 PM | 
| Vizard Tip of the Month: Use Tasks to Simplify your Code | Gladsomebeast | Vizard | 5 | 05-02-2008 05:30 PM |