Quantcast
Channel: Scripting - McNeel Forum
Viewing all articles
Browse latest Browse all 5800

VB Blocks inside blocks

$
0
0

I am trying to write a VB RhinoScript that finds objects with certain usertext associated with my Weight Estimating system, then show and select them. That part is easy. I also look through each block definition for a qualifying object, then show and select all instances of that block. So far so good. BUT, a qualifying block instance could itself be buried inside another block definition, which could be shown by another instance! The tree of block definitions and instances can get so convoluted I can’t seem to figure out how to get them all shown and selected. Is there a way to do this with VB?

arrBlocks = Rhino.BlockIds 'these are block definitions, not instances!
If Isarray(arrBlocks) Then
For Each strBlock In arrBlocks

	If Rhino.IsBlock(strBlock) Then					
		boolHasWtObjects = False 'default
		arrObjects = Rhino.BlockObjects(strBlock)
		If IsArray(arrObjects) Then
							
			'Determine If any objects with weight Userdata are In the block definition
			For Each strObject In arrObjects
				If Rhino.IsObject(strObject) Then
					If WeightObjectType(strObject) <> 0 Then boolHasWtObjects = True
				End If
			Next
							
			If boolHasWtObjects Then			
				'Turn on all layers of objects in the block definition
				For Each strObject In arrObjects
					If Rhino.IsObject(strObject) Then
						strLayer = Rhino.ObjectLayer(strObject)
						Call LayerOnOff(strLayer, True, True) 'parents too
						Rhino.ShowObject strObject
					End If
				Next

				'Show all the block instances that use this block
				arrBlockInstances = Rhino.BlockInstances(strBlock)
				If isarray(arrBlockInstances) Then
					For Each strBlockInstance In arrBlockInstances
						strLayer = Rhino.ObjectLayer(strBlockInstance)
						Call LayerOnOff(strLayer, True, True) 'parents too
						Rhino.ShowObject strBlockInstance									
					Next
				End If
								
				THIS IS WHERE I GET STUCK
				What about qualifying objects inside blocks inside blocks inside blocks!
			End If		
		End If
	End if
Next

End If

3 posts - 1 participant

Read full topic


Viewing all articles
Browse latest Browse all 5800

Trending Articles


Practice Sheet of Right form of verbs for HSC Students


Sarah Samis, Emil Bove III


ZARIA CUMMINGS


Need radio code for IVECO Delphi Aptiv FJ5 RBT M16


Black Angus Grilled Artichokes


Ed Sheeran – Sapphire – Pre-Single [iTunes Plus M4A]


Sunny Garcia’s Ex-Wife Colleen McCullough


99 God Status for Whatsapp, Facebook


Funeral of Sir Warwick Franklin


MHDD