Hi, im pretty new to maxscript.
my main scripting experience from
before has been in c# so there are many things that are a bit puzzling
to me. right now im scratching my head because of this one:
take this code for example:
splineObj = selection[1]
print (numsplines splineObj) as string
Outputs:
"3"
But this:
splineObj = filters.getmodorobj()
print (numsplines splineObj) as string
and this:
splineObj = modPanel.getCurrentObject()
print (numsplines splineObj) as string
gives this error:
-- No ""numSplines"" function for Line
but this:
splineObj = modPanel.getCurrentObject()
splineObj2 = selection[1]
print (classof splineObj) as string
print (classof splineObj2) as string
outputs:
line
line
so
my question is, how are these node returns (from selection[1] and
modPanel.getCurrentObject()) different? they have the same class, so in
my mind they should have the same methods. but obviously that is not
true
in any case im wondering how do i convert the
modPanel.getCurrentObject() or similar return node to something that
works like selection[1]? the reason is because im using in a function
where i would like to be passing both selection arrays and modPanel.getCurrentObject() nodes
im running into this issue in other places aswell like for example when im passing nodes to polyops.attach etc.
sorry if i didnt wrap my code blocks properly, i couldnt find an option for it
Replies
This is NOT so nice because it's confusing you with ClassOf.
modPanel.getCurrentObject() returns a base object ($.baseObject) not a node ($)
classOf will will convert a node input to a base object when no modifiers are present.
http://docs.autodesk.com/3DSMAX/16/ENU/MAXScript-Help/index.html?url=files/GUID-879ECFAD-7928-44B3-BCD7-276D53C89B52.htm,topicNumber=d30e180850
Hence
classOf $ == classOf $.baseObject
The only way I know to convert a base object to a node is:
numSplines (refs.dependents (modPanel.GetCurrentObject()))[1]
I'm not saying any of this makes sense. It's just how it is. MaxScript is an awesome language when you've got some experience behind it.