Notifications
Clear all

[Closed] Connecting maxscript to MAXSDK

I have exposed my function like


define_system_global("Edge_x", get_Edge_X, set_Edge_X); 

And call it inside maxscript


set_Edge_X Edge_x
set_Edge_Y Edge_y
set_Edge_Z Edge_z

But max complains that set_Edge_X is not defined. Where is the problem?
Thanks
Jack

5 Replies

http://docs.autodesk.com/3DSMAX/16/ENU/3ds-Max-SDK-Programmer-Guide/files/GUID-D814573C-23FA-476C-A48A-017038927C0A.htm

When the open_file_cf is exposed to maxscript, how does maxscript know there is a function called open_file already exposed. Do I have to declare it in maxscript.

In my applet, set_Edge_X is not defined, says maxscript.
Thanks
Jack

i expose my functions this way:


def_visible_primitive(MaxscriptFunctionName, "MaxscriptFunctionName"); //fn for maxscript

Value* MaxscriptFunctionName_cf(Value** arg_list, int count)
{ 
 //code
}

and in maxscript i call it

MaxscriptFunctionName arg1 ....

try destroyDialog name_edge catch()
rollout name_edge "Name Edge"
(
	struct edgeInfo (name, v1, v2, pos = (v1 + v2)/2)
	local edges = #()

	fn isPoly obj = isKindOf obj Editable_Poly

	global Edgex as function
	global Edgey as function
	global Edgez as function
	 
	-- maxscript exposed variables
	persistent global Edge_Name 
	persistent global Edge_x  
	persistent global Edge_y  
	persistent global Edge_z  
	 
	
	edittext name "Name: "
	pickbutton pick "NONE" autoDisplay:true filter:isPoly

	on pick picked it do
	(
	
		persistents.removeall()
		 
		if name.text.count < 1 do
			return messageBox "Edge name cannot be empty"
		if pick.object == undefined do
			return messageBox "No object selected"
		if pick.object.selectedEdges.count != 1 do
			return messageBox "Exactly one edge has to be selected"

		local verts = polyop.getEdgeVerts pick.object pick.object.selectedEdges[1].index

		
--		append edges (edgeInfo name:name.text v1:(polyop.getVert pick.object verts[1]) v2:((polyop.getVert pick.object verts[2])))

		local point3 ve1 = polyop.getVert pick.Object verts[1]
		local point3 ve2 = polyop.getVert pick.Object verts[2]
		
 

		local projx = abs( ve1.x - ve2.x as float) --7
		local projy = abs( ve1.y - ve2.y as float) --0
		local projz = abs( ve1.z - ve2.z as float) -- 0
		
		local Largest = 1 as integer
		
		if projx < 1.0e-6 and projy < 1.0e-6 do -- vertical
			Largest = 1
			
		
		if projy < 1.0e-6 and projz < 1.0e-6 do -- sideway
			Largest = 2
		
		if projx < 1.0e-6 and projz < 1.0e-6 do -- inner
			Largest = 3
			
		if projx > 1.0e-6 and projy > 1.0e-6 and projz > 1.0e-6 then
			Largest = 4			
			
		MessageBox (Largest as string)
		Edge_Name = name

		case Largest of
		(
		1: (
			 Edge_x = ve1.x as float
			Edge_y = ve1.y as float
			Edge_z = 0.0 
		   )
 
		 
		2: (	
		--	MessageBox (ve1.y as string)
			Edge_x = 0.0
			Edge_y = ve1.y as float
			Edge_z = ve1.z as float
			)
				
		3:	
			(
			Edge_x = ve1.x as float
			Edge_y =  0.0
			Edge_z = ve1.z as float 
			)
			
		4:
			(
			Edge_x = ve1.x as float
			Edge_y = ve1.y as float
			Edge_z = ve1.z as float
			)	
		)
		
		Edgex Edge_x
		Edgey Edge_y
		Edgez Edge_z
		 
			 
		 
		
	)
)
createDialog name_edge

Unable to make it recognized. The plugin was loaded successfully

I wonder why it isn’t recognized, I am sure the def_visible_primitive was called beforehand by putting a breakpoint there. However, the defined error is shown when calling the maxscript… (Edgex etc), however, these functions are not declared in the maxscripts, but isn’t maxscript a weakly typed language?

Thanks
Jack

Now the functions are recognized, but if I want maxscripts to write into the plugin (variables), should I use set_cf, or get_cf?
Thanks
Jack