'****************************************************************************************************** 'S&M Constraint script Tool Version 1.00000000000a(beta) by Saf Efstathiou and Miles Green 'HELLO! SIMPLY TAG SOME POINTS ON THE YOUR MESH AND RUN THE SCRIPT;IT WILL THEN PROMPT YOU TO PICK AN 'OBJECT(IT HAS TO BE A MODEL NULL); THIS WILL BE THE OBJECT THAT IS INSTANTIATED AND THEN CONSTRAINED TO THE 'POINTS YOU SELECTED EARLIER............FANTASTIC! P.S. THE SCRIPT ALSO ADDS A NORMAL CONSTRAINT TO 'MAKE SURE THE OBJECT IS ALIGNED PROPERLY WITH THE POINT IT WAS BEING CONSTRAINED TOO; AT THE MOMENT IT IS 'ACTIVATED IN THE 'X' AXIS, YOU MAY NEED TO CHANGE THIS TO BE THE 'Y' OR 'Z' AXIS IF YOUR OBJECT IS ALIGNED WRONGLY. 'ANY PROBLEMS, EMAIL ME! ':0) '******************************************************************************************************* dim mypickedobject set oSelection = Application.Selection '======================================================================================== 'THIS PART CREATES A COLLECTION OF ALL SELECTED OBJECTS AND SAVES THEM INTO MEMORY 'Set oSelection = GetValue( "SelectionList" ) 'For Each item In oSelection ' LogMessage item.Name 'Next '======================================================================================== for i = 0 to (oSelection.Count - 1) if ( oSelection(i).Type = "pntSubComponent" ) then logmessage "Found the following selected vertices on " & oSelection(i).Subcomponent.Parent3DObject.Name 'Selection of points myGeometry = oSelection(i).Subcomponent.Parent3DObject.Name logmessage myGeometry set subComponent = oSelection(i).SubComponent selectedIndices = subComponent.ElementArray 'selectobj oSelection(i).Subcomponent.Parent3DObject.Name '************************************************************************ 'BETTER STILL, IT WOULD BE NICE TO BE ABLE TO PICK AN OBJECT TO CONSTRAIN 'FROM WITHIN THE SCENE. call pickobject ("select the object u wish to constrain", ,mypickedobject) for j = 0 to Ubound( selectedIndices, 1 ) myselIndices = selectedIndices(j) SelectGeometryComponents myGeometry& ".pnt["& myselIndices & "]" fred2 = CreateCluster '************************************************************************ 'HERE, WE TAKE THE OBJECT WE PICKED EARLIER AND PASS IT THROUGH THE FOR LOOP set cloned_ob = Instantiate (mypickedobject) ApplyCns "ObjectToCluster", cloned_ob, fred2 '************************************************************************ 'THE NEXT PART APPLIES A 'NORMAL' CONSTRAINT ON THE BOLT SO THE BOLT ALLIGNS PROPERLY SetValue cloned_ob & ".kine.objclscns.upvct_active", True SetValue cloned_ob & ".kine.objclscns.upx", 1 SetValue cloned_ob & ".kine.objclscns.upy", 0 SetValue cloned_ob & ".kine.objclscns.upz", 0 'logmessage selectedIndices(j) next else logmessage "No points selected on " & oSelection(i).Name & "Type (" & oSelection(i).Type & ")" name_of_obj = oSelection(i) logmessage name_of_obj selectobj name_of_obj set SelList = GetValue("SelectionList") set aobj = selList(0) set aGeometry = aobj.activeprimitive.geometry 'logmesage aGeometry for k=0 to aGeometry.Points.Count - 1 SelectGeometryComponents aobj & ".pnt[" & k & "]" clustername = CreateCluster set cloned_ob = Clone( "bolt" ) 'set cloned_ob =Instantiate (bolt_model) ApplyCns "ObjectToCluster", cloned_ob, clustername next end if next