Notifications
Clear all

[Closed] link to this plugin

Hey. I am experimenting with writing plugins and find it pretty frustrating. I constantly run into system exceptions and stuff. My current problem is that I can’t find a way to set up multiple objects in a tool and link them to the plugin itself.

plugin camera testcam
name:"testcam " 
classID:#(0x7b72e71e, 0x1d3536e0)
category:"Standard"
extends: freecamera
(
			
	on getdisplaymesh do
	(
		if (meshObj == undefined) do
		(
		meshObj = createInstance box length:5 height:5 width:5
		)
		meshObj.mesh 

	)
	

	tool create
	(
		on mousePoint click do 
			(
				nodeTM.translation = gridPoint	--place the testcam where I clicked
				p = point pos:gridpoint -- create a point at the same place
				p.parent = this --link them ERROR
				#stop
			)
		
	)		
	
)

This plugin creates the testcam class. I want to add a point and link it to the node that is beeing created. But nodeTM only stores transformation data, and “this” doesn’t seem to be a node yet. So where did I go wrong?

Or when is the right time to add elements? I also tried the on create event but that is actually triggered right after I click the button, before I placed anything in a viewport. Even the on postcreate event seems to be triggered waaay too early.

Any help is appreciated.

2 Replies
 JHN
p.parent = (refs.dependentNodes this)[1]

Should fix it, as “this” points to the instance of the scripted plugin body/baseobject and not the actual node value.

-Johan

Thank you sooooo much Johan. You are a life saver. :bowdown: