Community
Fusion API and Scripts
Got a new add-in to share? Need something specialized to be scripted? Ask questions or share what you’ve discovered with the community.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Can't extrude rectangles that aren't zeroed in the z axis!

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
bucksanimals200hd
155 Views, 2 Replies

Can't extrude rectangles that aren't zeroed in the z axis!

I can't seem to figure this one out. I am working on a shipping crate design, where I input length, width, and height, and it creates all of the sketches and then extrudes each panel into a new component. However, the first two panels are working, but the third panel starts at a height of 48 inches. The code clearly designates the rectangle sketch at that height as the one to extrude, but it seems to be extruding the previous profile created. I will post the first three panels, and a picture of what it looks like! Please help! *In the picture I have highlighted the third component that is not where it is supposed to be at all, and cuts into the bottom of the second panel.

 

Code:

 

                sidePanel1StartPoint = adsk.core.Point3D.create(0, 0.5 * 2.54, 0)
                sidePanel1EndPoint = adsk.core.Point3D.create(0.5 * conv, 96 * 2.54, 0)
                sketchLines.addTwoPointRectangle(sidePanel1StartPoint, sidePanel1EndPoint)
                panelCount += 1
                prof = sketch1.profiles.item(int(panelCount))
               
                distance = adsk.core.ValueInput.createByReal(48 * conv)
           
                extrudes = rootComp.features.extrudeFeatures
                ext = extrudes.addSimple(prof, distance, adsk.fusion.FeatureOperations.NewComponentFeatureOperation)
                sidePanel2StartPoint = adsk.core.Point3D.create(0, 96 * conv, 0)
                sidePanel2EndPoint = adsk.core.Point3D.create(0.5 * conv, length + 0.5 * conv, 0)
                sidePanel2 = sketchLines.addTwoPointRectangle(sidePanel2StartPoint, sidePanel2EndPoint)
                panelCount += 1
                prof = sketch1.profiles.item(int(panelCount))
           
                distance = adsk.core.ValueInput.createByReal(48 * conv)
               
                extrudes = rootComp.features.extrudeFeatures
                ext = extrudes.addSimple(prof, distance, adsk.fusion.FeatureOperations.NewComponentFeatureOperation)
                sidePanel3StartPoint = adsk.core.Point3D.create(0, 0.5 * conv, 48 * conv)
                sidePanel3EndPoint = adsk.core.Point3D.create(0.5 * conv, 96 * conv, 48 * conv)
                sidePanel1 = sketchLines.addTwoPointRectangle(sidePanel3StartPoint, sidePanel3EndPoint)
                panelCount += 1
                prof = sketch1.profiles.item(int(panelCount))
               
                distance = adsk.core.ValueInput.createByReal(height - (48 * conv))
             
                extrudes = rootComp.features.extrudeFeatures
                ext = extrudes.addSimple(prof, distance, adsk.fusion.FeatureOperations.NewComponentFeatureOperation)
Labels (3)
2 REPLIES 2
Message 2 of 3

I think the problem is that you are assuming that the profiles are in a certain order. There's no guarantee that when you add geometry to a sketch that the resulting profiles will be in any logical or consistent order. You'll need to look at the geometric properties of the profiles to determine which one is which. Another solution is to create a sketch for each extrusion so you'll only have one profile in each sketch.

---------------------------------------------------------------
Brian Ekins
Inventor and Fusion 360 API Expert
Website/Blog: https://EkinsSolutions.com
Message 3 of 3

Ah, that makes sense! I will accept it as solution once I try that. I figured that the profiles were kept in an array, so I thought they would stay in the order I added them in!

 

Thank you,

 

Jeremiah

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Technology Administrators