How do I create NURBS lines/surfaces in Python?

How do I create NURBS lines/surfaces in Python?

dmitriZTSCC
Contributor Contributor
1,286 Views
6 Replies
Message 1 of 7

How do I create NURBS lines/surfaces in Python?

dmitriZTSCC
Contributor
Contributor

Can anyone point me to a Python example of automating 3DS Max to create NURBS lines/surfaces? I found some ClassIds, specifically these

ClassIds.NURBS_Imported_Objects = _MaxPlus.cvar.ClassIds_NURBS_Imported_Objects
ClassIds.NURBSCurveshape = _MaxPlus.cvar.ClassIds_NURBSCurveshape
ClassIds.NURBSSurf = _MaxPlus.cvar.ClassIds_NURBSSurf

But have no idea how to actually work with them, or even if they are relevant to what I want.

0 Likes
Accepted solutions (1)
1,287 Views
6 Replies
Replies (6)
Message 2 of 7

drew_avis
Autodesk
Autodesk
Accepted solution

I'm not sure about doing this with MaxPlus, but I was able to adapt the example in this help topic to use pymxs:

http://help.autodesk.com/view/3DSMAX/2020/ENU/?guid=GUID-62979DC6-3C9B-4A8C-B695-CA83E8AA1437

 

import pymxs
rt = pymxs.runtime

# create an empty NURBSSet object
nset = rt.NURBSSet ()
# create a new NURBSCVCurve and set the knots and CVs
c = rt.NURBSCVCurve( name="CV Curve", order=4, numCVs=4, numKnots=8)
for k in range(1,5) :
	rt.setKnot( c, k, 0)
	rt.setKnot( c, (k+4), 1 )
cv = rt.NURBSControlVertex( rt.Point3(0, 0, 50))
rt.setCV( c, 1, cv)
cv.pos = rt.Point3(-100, 0, 50)
rt.setCV( c, 2, cv)
cv.pos = rt.Point3(-100, 100, 50)
rt.setCV( c, 3, cv)
cv.pos = [0, 100, 50]
rt.setCV( c, 4, cv)
# add the NURBSCVCurve object to the set
rt.appendObject( nset, c)
# create the NURBS object from the NURBSSet
n = rt.NURBSNode( nset, name="nurbs01", pos=rt.Point3(10,0,0))

Hope that helps,

Drew



Drew Avis
Content Experience Designer
0 Likes
Message 3 of 7

dmitriZTSCC
Contributor
Contributor

Thanks. Is it possible to mix MaxPlus and pymxs in the same script?

0 Likes
Message 4 of 7

drew_avis
Autodesk
Autodesk

You can, that is not a problem.  But you can't exchange objects/values between them.  

 

Drew



Drew Avis
Content Experience Designer
Message 5 of 7

dmitriZTSCC
Contributor
Contributor

Another question, if I may: where exactly do I find the pymxs.py file? I need to include it in my project in order to get the symbols (autocompletion and all that). I only see a pymxsExtend.py file that has a import pymxs statement in it, but where is pymxs itself? (i.e., the interface definitions)

0 Likes
Message 6 of 7

drew_avis
Autodesk
Autodesk

So unfortunately there is no "pymxs.py".  Pymxs is actually a wrapper/interpreter for the MAXScript engine, so pymxs code gets re-interpreted as MAXScript and sent to the runtime.  You could generate an API file for MAXScript and modify it to look like a python syntax file.  I haven't tried this, but I don't see why it wouldn't work.  MXS API generation is now available "out of the box" in 2020.1 update; see generateAPIList() here:  http://help.autodesk.com/view/3DSMAX/2020/ENU/?guid=GUID-53F8D6CE-A5A6-4353-BE48-4298BBE107DE

 

Hope that helps,

Drew



Drew Avis
Content Experience Designer
Message 7 of 7

yuanbowei
New Member
New Member

how to realize this in motion builder? please.

0 Likes