IntersectRay parameters for Mesh

IntersectRay parameters for Mesh

Anonymous
Not applicable
974 Views
3 Replies
Message 1 of 4

IntersectRay parameters for Mesh

Anonymous
Not applicable

Hello ! Recently started testing python api to automate my purposes, but i have some trouble with using IntersectRay method for Mesh object. First I create a box with dimensions 10x10x10 on the path of ray tracing  in scene and convert it to mesh object. After executing this code i get Runtime error

 

import MaxPlus
direction_point = MaxPlus.Point3(0, 1, 0)
start_point = MaxPlus.Point3(0, 0, 0)
ray = MaxPlus.Ray()
ray.SetPoint(start_point)
ray.SetDirection(direction_point)
r_node = MaxPlus.Core.GetRootNode()
obj = r_node.GetChild(0).GetObject()
mesh = MaxPlus.GeomObject._CastFrom(obj)
p = 0.1
n = MaxPlus.Point3(1, 1, 1)
bool = mesh.IntersectRay(ray, p, n)

 

Runtime error content:

 

-- Runtime error: 
Traceback (most recent call last):
 File "C:\Program Files\Autodesk\3ds Max 2017\MaxPlus.py", line 12333, in <IntersectRay>
NotImplementedError: Wrong number or type of arguments for overloaded function 'Object_IntersectRay'.
 Possible C/C++ prototypes are:
 Autodesk::Max::Object::IntersectRay(Autodesk::Max::Ray &,float &,Autodesk::Max::Point3 &,TimeValue)
 Autodesk::Max::Object::IntersectRay(Autodesk::Max::Ray &,float &,Autodesk::Max::Point3 &)

I can't understand what I need to pass as parameters to get the working result. Searching examples in 3DS Max help is too unsuccessful.

 

 

 

0 Likes
975 Views
3 Replies
Replies (3)
Message 2 of 4

malcomarmstrong
Advocate
Advocate

Is it because you are passing too many parameters to the intersect ray? In the docs, you need to pass 2 parameters to intersect ray (node, ray) and you are passing 3 values. Whats the third for?

 

Perhaps its different for MaxPlus, not looked into it yet. Just thoughts on initial look at your code.

 

regards

0 Likes
Message 3 of 4

Anonymous
Not applicable

I found short description of "IntersectRay" function in 3d max docs link. I think the symbol " & " in C++ means that the argument must be passed by reference and the result of the intersection will be written there . I can not understand how to do it using Python, all in vain.

0 Likes
Message 4 of 4

malcomarmstrong
Advocate
Advocate

AH, you are using python in max 2014. Known to have issues. The current implementations (MaxPlus and pymxs) do not currently fare better. Autodesk have been a bit lapse with a proper wrapped version, so I am not at all surprised that the implementation you are using has issues. Maxplus is too longwinded and pymxs does not even have a complete set of documentation, let alone a complete wrapper for maxscript commands. Prob best to wait till 2020, see if they get it together.

 

Probably not what you wanted to hear, but its pretty much what is going on with max python.

0 Likes