Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- dim ChildMaterials, ObjCollection, oSelecto, oBaseObj, oCls, oBaseClusters, oChildren, oItem, oClusters
- 'Create a collection to add the materials to
- Set ChildMaterials = CreateObject( "XSI.Collection" )
- 'Create a collection for adding objects to
- Set ObjCollection = CreateObject( "XSI.Collection" )
- if application.selection.count = 0 then
- LogMessage "Select an object"
- PickObject "Select an object", " ", oSelecto
- 'add oSelecto to ObjCollection collection
- ObjCollection.add oSelecto
- else
- 'Add the application selection to ObjCollection collection
- Set oSelecto = Application.Selection
- for i = 0 to (oSelecto.Count - 1)
- ObjCollection.add oSelecto(i)
- next
- end if
- for x = 0 to (ObjCollection.count - 1)
- set oBaseObj = ObjCollection(x)
- DeselectAll
- 'select the object's material
- SelectMaterialsUsedBy oBaseObj
- 'add the material to the collection
- ChildMaterials.add application.Selection(0)
- 'if it is a polygon / nurb surface then look for clusters and add their materials too
- if oBaseObj.type = "polymsh" or oBaseObj.type = "surfmsh" then
- set oBaseClusters = oBaseObj.ActivePrimitive.Geometry.Clusters
- for each oCls in oBaseClusters
- DeselectAll
- 'select the cluster's material
- SelectMaterialsUsedBy oCls
- 'add it to the ChildMaterials collection
- ChildMaterials.add application.Selection(0)
- next
- end if
- 'use findchildren to find the children ;)
- Set oChildren = oBaseObj.FindChildren2
- 'Itterate a simple material selection for each child and add to the collective
- for i = 0 to (oChildren.Count - 1)
- DeselectAll
- 'Select the child's material
- SelectMaterialsUsedBy oChildren(i)
- 'add it to the ChildMaterials collection
- ChildMaterials.add application.Selection(0)
- 'if it is a polygon / nurb surface then look for clusters and add their materials too
- if oChildren(i).type = "polymsh" or oChildren(i).type = "surfmsh" then
- for each oItem in oChildren
- on error resume next
- set oClusters = oItem.ActivePrimitive.Geometry.Clusters
- if ( err = 0 ) then
- for each oCls in oClusters
- DeselectAll
- 'select the cluster's material
- SelectMaterialsUsedBy oCls
- 'add it to the ChildMaterials collection
- ChildMaterials.add application.Selection(0)
- next
- end if
- next
- end if
- next
- next
- 'Select the collection
- selectobj ChildMaterials
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement