Ilogic code to get the area in sheet metal

Ilogic code to get the area in sheet metal

mdavis22569
Mentor Mentor
1,179 Views
3 Replies
Message 1 of 4

Ilogic code to get the area in sheet metal

mdavis22569
Mentor
Mentor

Hi ...

 

I'm curious has written a code to get the area of a part in Sheet Metal ....

 

 

(Ilogic isn't my thing... )

 

thanks for the help


Did you find this reply helpful ? If so please use the Accept as Solution or Kudos button below.

---------
Mike Davis

EESignature

0 Likes
Accepted solutions (1)
1,180 Views
3 Replies
Replies (3)
Message 2 of 4

Curtis_Waguespack
Consultant
Consultant
Accepted solution

Hi mdavis22569,

 

If you're looking for the surface area of the face of a sheet metal flat pattern I think this will work for you.

 

Adapted from here:

http://forums.autodesk.com/t5/inventor-customization/flat-pattern-area/m-p/2689725#M32129

 

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

 

 

Dim oDoc As PartDocument
oDoc = ThisApplication.ActiveDocument
   
Dim oDef As SheetMetalComponentDefinition
oDef = oDoc.ComponentDefinition
   
Dim oFlatPattern As FlatPattern
oFlatPattern = oDef.FlatPattern
   
Dim oTransaction As Transaction
oTransaction = ThisApplication.TransactionManager.StartTransaction(oDoc, "Find area")
   
Dim oSketch As PlanarSketch
oSketch = oFlatPattern.Sketches.Add(oFlatPattern.TopFace)
   

Dim oEdgeLoop As EdgeLoop
    For Each oEdgeLoop In oFlatPattern.TopFace.EdgeLoops
        If oEdgeLoop.IsOuterEdgeLoop Then
            Exit For
        End If
    Next
   
Dim oEdge As Edge
    For Each oEdge In oEdgeLoop.Edges
        Call oSketch.AddByProjectingEntity(oEdge)
   Next
   
Dim oProfile As Profile
oProfile = oSketch.Profiles.AddForSolid
   
Dim dArea As Double
    dArea = oProfile.RegionProperties.Area
   
   
oTransaction.Abort
MessageBox.Show("External surface area = " & dArea & " cm^2", "iLogic")
   

 

EESignature

0 Likes
Message 3 of 4

mdavis22569
Mentor
Mentor

Thank you Curtis, it's not for me but for another person who emailed me ...

 

This isn't my area ... so thank you .. I did let him know you were the one who did it.

 

 

 

I'm still working on the code you gave me before ...for changing the BOM Structucing numbers by starting with 10, and do in increments of 10. 

 

 

Mike


Did you find this reply helpful ? If so please use the Accept as Solution or Kudos button below.

---------
Mike Davis

EESignature

0 Likes
Message 4 of 4

RolfEven
Enthusiast
Enthusiast

Hi Curtis,

 

Thank you for posting this iLogic rule. At first I was not able to run the code, it halted on an error. After some investegating I found, with help from others, that the code is dependent on an Application Options setting. If in Sketch-tab, setting "Project objects as construction geometry" = True, the code fails.

Application Options.png

I have tried a few things to have the projected geometry as normal lines. One thing I found from Google and a other one from Inventor API help document, but I'm not able to get the code working. iLogic says error on my attempts to fix this, and I am 100 % sure I'm doing things wrong. Are you able to point me in the right direction on how to modify your original code to ignore this application options setting.

Attempt 1.pngAttempt 2.png

/Rolf Even

0 Likes