Notifications
Clear all

[Closed] Vert constraint

Ive searched online for a good “object to vert” link script and I stumbled onto a really
good one.

MainFloater = NewRolloutFloater "Link2Vert" 180 315
 
 
 Rollout Link2Vert "Link Vertex" (
 
 group "Pick Vert" (
 
 Label getvert1L "Select a vertex to be parent"
 Label getvert2L "then hit 'Get Selected Vert'"
 Button GetVert_Button "Get Selected Vert(s)"
 Label vertnumL "Vertex Number: (none selected)"
 
 ) -- close group
 
 group "Pick Child" (
 
 Label childL "Select Child Object"
 PickButton GetChild_PB "Get Child"
 Label childnameL "Child Object: (none)"
 
 ) -- close group
 
 group "Connect " (
 
 Button LinkME_Button "Connect!" enabled:on
 
 ) --close group
 -----------------------------------------------------------------------------
 on GetVert_Button pressed do (
 
 -- 	getvertselection
 
 vertnum = (polyOp.getVertSelection $)
 vertnumL.text = "Vertex Number: " + (vertnum as string)
 VertPicked = true
 if ChildPicked == true do LinkME_Button.enabled = on
 
 ) -- close on getvert
 -----------------------------------------------------------------------------
 on GetChild_PB picked obj do (
 
 
 -- 	getchildselection	
 	
 Child_Obj = obj
 childnameL.text = "Child Object: " + Child_Obj.name
 ChildPicked = true
 if VertPicked == true do LinkME_Button.enabled = on
 
 
 ) --close on getchild
 -----------------------------------------------------------------------------
 on LinkME_button pressed do (
 
 Child_Obj.position.controller = position_script
 Child_Obj.position.controller.script = ("pos = getvert $" +  (parentOBJ.name) + " " + (vert.text))
 	
 	
 ) --close on linkme
 
 ) -- Close Rollout
 
 addRollout Link2Vert MainFloater -- Add Rollout to the main floater  

Ive had to fix a few mistakes in the script and almost got it to work.
As you can see from the script there is a part that says:

if ChildPicked == true do LinkME_Button.enabled = on

and viceversa for “Vertpicked”. I believe the code is correct because if I switch those 2 in the script (Thus vert into getvertsection and child into getchildsection)
the button will be enabled. However on their current location the button doesnt want to enable.

So for now I did enabled:on to skip that process.

But now im having trouble with the link part of the script. If I press the Connect button the error:

Unknown property: “pos” in undefined

pops up.

I have searched from here till Tokyo but I cannot find the answer but I think im almost there. Anyone know what the problem is?

3 Replies
 JHN

Replace the LinkME_button eventhandler with :


 on LinkME_button pressed do (
	
	local vertnum = ((polyOp.getVertSelection $) as array)[1]
	local theController = position_script()
	theController.addNode "theTarget" $
	theController.script = "getPointPos theTarget " + (vertnum as string)

	GetChild_PB.object.position.controller = theController
	 
) --close on linkme

There’s no safety in your code whatsoever, so picking the wrong objects etc will make it crash. “getPointPos” will only work in max 2008 and newer!

Cheers,
-Johan

Hey Johan, hope you’re well. Yah I noticed. Had to shutdown max a few times by taskmanager as I didn’t get any response, but didn’t know where to built the safeproof code and which code to use. I do have to use an if then code for the “pick vert” button, now when the object is not an editable poly or no verts are selected the script crashes, but will work on that today.

Thanks for the help btw, the script works. Also really great that the dummy object moves to the vert position immediately, I didnt get that to work and wanted to use the pick point script for that separately. I only have some problems with the refresh of the dummy locations after I moved the verts.

Thanks mate.

So it seems that the refresh thing is getting worse. Im rendering a scene with VRAY + Vraycameras and use lightcache for the secondary bounces. Every frame is rendered in 3 passes and it seems the first pass is completely off. The end result however is completely correct. So:

renderpass 1: object is in previous position

renderpass 2: correct
finalpass: correct.

Ive narrowed it down that when I turn Lightcache off in VRAY settings the frame will be rendered okay, but then of course it doesn’t render in 3 passes and in the settings that I want, so completely useless.
.
Is there a way to resfresh the current scene, state, cameras, view (well that I know (redrawviews)) before it renders the first pass? Not that it matters much but it would be lovely-er and more secure to work with.

thnx