How to get an extrusion name

How to get an extrusion name

joao_mirandaEFM7E
Explorer Explorer
245 Views
1 Reply
Message 1 of 2

How to get an extrusion name

joao_mirandaEFM7E
Explorer
Explorer

I made a script to do an extrusion and define a name of "Tubo ..."

 

            profile = sketch.profiles.item(1)
            extent_distance = adsk.core.ValueInput.createByReal(ExtrusionLengthSelect)
            extrudes = root_comp.features.extrudeFeatures
            extrude1 = extrudes.addSimple(profile, extent_distance,
                                          adsk.fusion.FeatureOperations.NewComponentFeatureOperation)
            extrude1.name="Tubo "+str(float(fHeight))+"x"+str(float(fWidth))+"x"+str(float(wallThick))
 

Now I want a way to get the extrusion name. But I couldn't do it.

My code

 

        extname = root.features #.extrudeFeatures
        bBox2: adsk.core.BoundingBox3D = root.preciseBoundingBox #str(extrudes.item(0).name)
        if extname.count > 0:
            ext=extname.item(0)
            #fun_dict = {t.__name__: t for t in extname}
            flatSize2 = [
            str(ext),
            round(abs(bBox2.maxPoint.x - bBox2.minPoint.x)*10,2),
            round(abs(bBox2.maxPoint.y - bBox2.minPoint.y)*10,2),
            round(abs(bBox2.maxPoint.z - bBox2.minPoint.z)*10,2),
        ]
0 Likes
246 Views
1 Reply
Reply (1)
Message 2 of 2

boopathi.sivakumar
Autodesk
Autodesk

Hi @joao_mirandaEFM7E 

Since you are adding this a new componenet then the extrude will not be in the root component any more it will part of the occurrance component 

 Hope this helps

profile = sketch.profiles.item(0)
extent_distance = adsk.core.ValueInput.createByReal(10)
extrudes = rootcomp.features.extrudeFeatures
extrude1 = extrudes.addSimple(profile, extent_distance,
                                adsk.fusion.FeatureOperations.NewComponentFeatureOperation)

name = "Tubo "+str(float(10))+"x"+str(float(10))+"x"+str(float(10))
extrude1.name= name


extFeatures = rootcomp.occurrences.item(0).component.features.extrudeFeatures # get the new component and get extrude features
extfure = extFeatures.itemByName(name) # get the extrude feature by name

if extfure is not None: # if the extrude feature is found

    bBox2 = extfure.parentComponent.preciseBoundingBox
    print(extfure.name)
    print(round(abs(bBox2.maxPoint.x - bBox2.minPoint.x)*10,2),
        round(abs(bBox2.maxPoint.y - bBox2.minPoint.y)*10,2),
        round(abs(bBox2.maxPoint.z - bBox2.minPoint.z)*10,2))

Boopathi Sivakumar
Senior Technology Consultant

0 Likes