Notifications
Clear all
[Closed] Getting spline vertex in maxplus
Nov 26, 2014 12:02 am
i’m trying to learn Maxplus but unfortunately there is not much information around.
does anyone know how you can get a spline vertexes? this spline can also have several closed or open sub splines
what i want is to send a list of vertex positions to python and after processing them return a new list as an array to create a new spline.
appreciate any input.
Guillermo Leal.
3 Replies
Nov 26, 2014 12:02 am
You mean maxscript?
getKnotPoint is what you need
Example: getKnotPoint $ 1 1
Nov 26, 2014 12:02 am
thanks for your replay but no i meant python.
the maxscript version would be like this.
fn getVertex splines =
(
thePoints = #() -- array of vertex positions
theShapes = for o in splines where superclassof o == Shape collect o
for o = 1 to theShapes.count do
(
local subLineCount = numSplines theShapes[o] -- number of splines in the current spline
for s = 1 to subLineCount do
(
local numOfPoints = (numknots theShapes[o] s)
for i = 1 to numOfPoints do
(
tmpNod = [0,0,0]
tmp = (getknotpoint theShapes[o] s i)
tmpNod.x = tmp.x
tmpNod.y = tmp.y
tmpNod.z = tmp.z
append thePoints tmpNod
)
)
)
return thePoints
)
getVertex selection
Nov 26, 2014 12:02 am
if anyone is interested this is one way to do it.
def getVertexfromShape(node, forceConvert=False):
points = []
# check if its a spline
if node.Object.GetClassName() == "SplineShape":
state = node.EvalWorldState()
obj = state.Getobj()
mxShp = MaxPlus.SplineShape._CastFrom(obj)
# make is a beziershape so we can get the vertices
Bshp = MaxPlus.BezierShape._CastFrom(mxShp.GetShape())
print("Shape has {} vertices and the shape is {}".format(Bshp.GetNumVerts(), isOpen))
numVerts = Bshp.GetNumVerts()
for v in range(numVerts):
points.append(Bshp.GetVert(v))
return points
else:
print "the shape must be SplineShape"
return 0
and we use it like:
n = MaxPlus.SelectionManager.GetNode(0)
p = getVertexfromShape(n)
Guillermo Leal