Sketch.profiles and extrusion.

Sketch.profiles and extrusion.

gscotti
Enthusiast Enthusiast
490 Views
1 Reply
Message 1 of 2

Sketch.profiles and extrusion.

gscotti
Enthusiast
Enthusiast

I'm trying the following code.The problem here is that the profiles contains inner profileLoops. Is there any way to filter that out, or should I create another profile and includes only the outer profile in profileLoops? This sounds very confusing to me.

 

    # search for profiles that spans larger boxes than registered maxp    
    newprofiles = {}
    for p in sketch.profiles:
        if not p.isValid:
            continue
        bbox = p.boundingBox
        d = helper.diff(bbox.minPoint,bbox.maxPoint) # diffs two points and returns vector
        if d.length > maxp[0]:
            newprofiles[d.length] = p

    # sort and pick the largest 3
    largest = []    
    for a in sorted(newprofiles, reverse=True):
        if len(largest) < 3:
            largest.append(newprofiles[a])
        else:
            break
                
    pedestal = largest[0]
    einput = extrudes.createInput( pedestal, adsk.fusion.FeatureOperations.NewBodyFeatureOperation)
    distance = adsk.core.ValueInput.createByReal(-stepdown)
    einput.setDistanceExtent(False,distance)
    extrudes.add(einput)

As a result, all profiles are chosen instead of the outermost one (which would span the largest bounding box). See the screenshot

 

0 Likes
491 Views
1 Reply
Reply (1)
Message 2 of 2

gscotti
Enthusiast
Enthusiast

I think my geometry is bad, or offset operation creates a bogus profile. With a simpler body, the script work correctly.

I'll try something different.

 

0 Likes