Notifications
Clear all

[Closed] Detect Whether convertToPoly "Fails"

I’m creating several closed splines from 3rd party coordinates, some of them with bezier points. Some of the data is “bad” as the curves cause self-intersection. In that case “convertToPoly” works but nothing is shown.

I need some way of knowing that the spline is problematic.
The “Shape Check” utility picks it up but it doesn’t seem scriptable.

I’m a MaxScript beginner, What could I check on the converted poly?

3 Replies
1 Reply
(@miauu)
Joined: 11 months ago

Posts: 0

Check the count of the faces. For example:



(
    spl = $Shape001
    
    splAsPolyObj = convertToPoly spl
    
    if splAsPolyObj.numfaces != 0 then
        print "GOOD"
    else
        print "BAD"
)


Thank you! Just what I was looking for.

you can also use sdk methods to check for spline self-intersections and its intersections with other splines


(
    g = (dotNetClass "Autodesk.Max.GlobalInterface").Instance
    inode = g.coreinterface7.getinodebyhandle $.inode.handle
    shp = ((inode.EvalWorldState (int currenttime) true).obj).shape_
    splines = for i=0 to shp.SplineCount-1 collect shp.GetSpline i

    -- showmethods splines[1]
    -- show splines[1]
    
    for i=1 to splines.count do
    (
        format "Spline % is self-intersecting: %
" i (splines[i].SelfIntersects)
        
        for j=i+1 to splines.count where splines[i].IntersectsSpline splines[j] do
        (
            format "Spline % intersects spline %
" i j
        )
        
    )

)