Community
Inventor Forum
Welcome to Autodesk’s Inventor Forums. Share your knowledge, ask questions, and explore popular Inventor topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Calculate area of extrusion without user parameters?

15 REPLIES 15
SOLVED
Reply
Message 1 of 16
Infoseeker
3714 Views, 15 Replies

Calculate area of extrusion without user parameters?

I have a part with very irregular shape created by projecting geometry of other parts. 

I wondered if there is any way of calculating area of this extrusion instead of dimensioning the sketch and creating equasions in user parameters? This would take forever... 

15 REPLIES 15
Message 2 of 16

Hi Infoseeker, 

 

I don't suppose this is a sheet metal part is it?

Also, is the end goal to report the area on a drawing, or are you just needing to measure it?

 

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


Message 3 of 16

No, its a regular part.

Message 4 of 16
Infoseeker
in reply to: Infoseeker

I guess I could convert it if it opens more possibilities.

The problem is that the sketch/extrusions are net-like so its not one solid extrusion but rather a bunch of extruded geometries, with hollow spaces between them ...

Message 5 of 16

Hi Infoseeker,

 

You can place the Area on a drawing using the Text tool as shown here. Will that work or are you needing something else (like showing it in the BOM)?

 

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

 

 

Autodesk Inventor Get Area on Drawing.png

Message 6 of 16

I need it for BOM.

Message 7 of 16

Hi Infoseeker,

 

Here's an iLogic example that will write the surface area to a custom iProperty. You can then pull that iProperty into the BOM.

 

See attached part also.
 

This is just a basic example, you might want the result placed as a User Parameter or need to have it formatted better,  etc.  Which can be done.

 

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


 

'update the mass properties of the file
ThisApplication.CommandManager.ControlDefinitions.Item("AppUpdateMassPropertiesCmd").Execute

'define the current document
oDoc =ThisDoc.Document

'define the design tracking properties
Dim oDTP As PropertySet = oDoc.PropertySets.Item("Design Tracking Properties") 
Dim oArea As Double 
'get the surface area
oArea =  (oDTP.Item("SurfaceArea").Value)

'define the custom iProperty name
Dim propertyName1 As String = "Surface Area"

'define custom prp[erty collection
oCustomPropertySet = oDoc.PropertySets.Item("Inventor User Defined Properties")

'look for the custom iProperty and create it if not found
Try
'set property value
iProperties.Value("Custom", propertyName1) = oArea
Catch
' Assume error means not found so create it
oCustomPropertySet.Add("", propertyName1)
iProperties.Value("Custom", propertyName1) = oArea
End Try

'remove this if you don't want to see the result
MessageBox.Show(oArea , "iLogic")

 

Message 8 of 16

Thanks Chris, iLogic definitely add new dimension to Invenor.

Message 9 of 16
Infoseeker
in reply to: Infoseeker

It works great, the only thing I need to change the iproperty's name to Quantity and units to SF - when I replace Surface Area with Quantity in the rule, I get an error.

Message 10 of 16

Hi Infoseeker,

 

Here's a modified version. This one writes the surface area to a User Parameter named "Quantity", and then exports that to a custom iProperty.

 

The units are pulled from the file's Document Settings > Unit setting. So if the file is set to inches, the surface area is set to square inches, if the Document Settings > Unit setting is set to Feet then the surface area is set to square feet, and so on. 

 

But if you need the Document Settings > Unit setting to be inches and the surface area to be square feet, or something like that where the untis don't match we can update the code to do so.

 

Attached is an example file with the rule set up already also.

 

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


 

 

'define the name to use as the user Parameter & custom iProperty
'which will hold the surface area
Dim sAreaParam As String
sAreaParam = "Quantity"

'update the mass properties of the file
ThisApplication.CommandManager.ControlDefinitions.Item("AppUpdateMassPropertiesCmd").Execute

'define the current document
Dim oDoc As PartDocument
oDoc =ThisDoc.Document

'set a reference to the compdef. 
Dim oCompDef As PartComponentDefinition 
oCompDef = oDoc.ComponentDefinition

'get the UnitsOfMeasure collection for  the file 
Dim oUOM As UnitsOfMeasure
oUOM = oDoc.UnitsOfMeasure

'get the current length units from the UnitsOfMeasure collection 
Dim eLengthUnits As UnitsTypeEnum 
eLengthUnits = oUOM.LengthUnits 

'define the design tracking properties
Dim oDTP As PropertySet 
oDTP = oDoc.PropertySets.Item("Design Tracking Properties") 

'get the surface area from the design tracking properties
' this will be in Inventor's default internal units (cm)
Dim dSA As Double
dSA = (oDTP.Item("SurfaceArea").Value)

'convert surface area to the file's current units
Dim dArea As Double 
If eLengthUnits = 11272 Then '11272 = InchLengthUnits 
dArea = oDoc.UnitsOfMeasure.ConvertUnits(dSA, "cm cm", "in in")
Else If eLengthUnits = 11273 Then '11273 = FootLengthUnits 
dArea = oDoc.UnitsOfMeasure.ConvertUnits(dSA, "cm cm", "ft ft")
Else If eLengthUnits = 11270 Then '11270 = MeterLengthUnits
dArea = oDoc.UnitsOfMeasure.ConvertUnits(dSA, "cm cm", "m m")
Else If eLengthUnits = 11268 Then '11268 = CentimeterLengthUnits
dArea = dSA 'no conversion needed
Else If eLengthUnits = 11269 Then '11269 = MillimeterLengthUnits
dArea = oDoc.UnitsOfMeasure.ConvertUnits(dSA, "cm cm", "mm mm")
Else If eLengthUnits = 11271 Then '11271 = MicronLengthUnits
dArea = oDoc.UnitsOfMeasure.ConvertUnits(dSA, "cm cm", "micron micron")
End If

' create a string defining the units
Dim strAreaUnits As String
strAreaUnits = oUOM.GetStringFromType(oUOM.LengthUnits) & "^2"

'get a string containing the area
Dim strArea As String
strArea = oUOM.GetStringFromValue(dArea, strAreaUnits)

'create a user parameter
Dim oUserParam As UserParameter

'show no error message if the parameter is not found / does not exist
Parameter.Quiet = True
'check for the parameter 
If Parameter(sAreaParam) Is Nothing  Then
'create it if the value is nothing (meaning it doesn't exist)
oUserParam = oCompDef.Parameters.UserParameters.AddByValue(sAreaParam, dArea, strAreaUnits)
Else 
'set the value of the parameter if it does exist
Parameter.Param(sAreaParam).Units = strAreaUnits
Parameter(sAreaParam) = dArea
End If

'set the user parameter
oUserParam = Parameter.Param(sAreaParam) 
'export user parameter as an iProperty 
oUserParam.ExposedAsProperty = True

'format the custom iProperty 
'set iProperty to custom format
oFormat = oUserParam.CustomPropertyFormat
'set iProperty to Text type
oFormat.PropertyType = Inventor.CustomPropertyTypeEnum.kTextPropertyType
'set iProperty number of decimal places
oFormat.Precision = Inventor.CustomPropertyPrecisionEnum.kThreeDecimalPlacesPrecision
'set iProperty unit using the file's current unit of measure
oFormat.Units = oUOM.GetStringFromType(oUOM.LengthUnits) & "^2"
'set iProperty to show the unit string
oFormat.ShowUnitsString = True

'update the file so the custom iProperty is output
InventorVb.DocumentUpdate()

'remove this if you don't want to see the result
'display the custom iProperty in a message box
MessageBox.Show("The surface area is " & iProperties.Value("Custom", sAreaParam), "iLogic")

 

Message 11 of 16

It works great except even with the change of units in Doc Settings, in^2 doesnt change to ft^2.

I would prefer ft^2 come from the rule.

Also, in your previous example the iproperty came as a numeric value, this time its a text value which makes it impossible to use it when subsittuting values in BOM's.

Again, iLogic is really impressive, thanks a lot for the examples!

 


 

 

Message 12 of 16

Hi Infoseeker,

 

Here is another version based off of the first. It calcs the surface area as square feet regardless of the part units used, and it writes to the custom iProperty as a number. it also formats the number of decimal places used, so you can adjust that if needed.

 

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

 

 

'define the name to use as the custom iProperty
'which will hold the surface area
Dim propertyName1 As String
propertyName1= "Quantity"

'update the mass properties of the file
ThisApplication.CommandManager.ControlDefinitions.Item("AppUpdateMassPropertiesCmd").Execute

'define the current document
oDoc =ThisDoc.Document

'define the design tracking properties
Dim oDTP As PropertySet = oDoc.PropertySets.Item("Design Tracking Properties")

'get the surface area
Dim dArea As Double
dArea = oDoc.UnitsOfMeasure.ConvertUnits((oDTP.Item("SurfaceArea").Value), "cm cm", "ft ft")

'set the number of decimal places
Dim i As Integer
i = 3

'format the number
Dim dAreaShort As Double
dAreaShort = Round(dArea, i )

'define custom property collection
oCustomPropertySet = oDoc.PropertySets.Item("Inventor User Defined Properties")

'look for the custom iProperty and create it if not found
Try
'set property value
iProperties.Value("Custom", propertyName1) = dAreaShort
Catch
' Assume error means not found so create it
oCustomPropertySet.Add("", propertyName1)
iProperties.Value("Custom", propertyName1) = dAreaShort
End Try

'remove this if you don't want to see the result message
MessageBox.Show("The surface area is " & dAreaShort & " ft^2" , "iLogic")

 

Message 13 of 16

with the code to pick to translate to any units, is it possible to have a box come up to ask for which units you want to convert to?

Image and video hosting by TinyPic
..........................................................................................................................
Did you find this reply helpful ? If so please use the Accept as Solution or Kudos button below.
..........................................................................................................................


See My LinkedIn Profile
Message 14 of 16

Hello Curtis,

Do you or anyone else know how to measure the surface area of one specific feature or surface with iLogic within a model?  If the surface isn't planar then using the area measure snippet is out of the question.  This would be very helpful to me.

Thanks

Message 15 of 16

Is there a way this ilogic code can measure just "one surface" area such as when using the measure area tool and selecting a face? 

 

For example; I have a piece of irregular shaped grating that has an area of 25.477 ft sq when using the measuring tool. The ilogic porgram calculates that area as 58.731 ft sq as it adds all the surfaces (top/bottom. both sides, both ends).

 

Inventor Professional 2020
HP Z440, Xeon E5-1650 @ 3.6GHz
32GB Ram
GTX 1080
Windows 10
Message 16 of 16

Hi jeffsteiger6735,

 

 

Let's say I have a part with an extrusion called Extrsuion1, what we can do is look at the end face of that extrusion, and get the area of that face, as in this example code. This example evaluates the start face and end face, and notice in the example images when I add a cut that goes through the end face, but not the start face, the results reflect this.

 

So the code might vary depending on your model, the feature name, and the faces being evaluated.

 

Note that we could use the SideFaces collection as well.

 

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

Surface Area1.PNG

 

Surface Area2.PNG

 

'define the current document
Dim oDoc As PartDocument
oDoc = ThisApplication.ActiveDocument

' a reference to the component definition.
Dim oCompDef As PartComponentDefinition
oCompDef = oDoc.ComponentDefinition

Dim oExtrude1 As ExtrudeFeature
oExtrude1 = oCompDef.Features.ExtrudeFeatures("Extrusion1")

'get the end face of extrusion1
Dim oEndFace As Face
oEndFace = oExtrude1.EndFaces.Item(1)

'get area of face
Dim dArea1 As Double
dArea1 = Round(oEndFace.Evaluator.Area ,4)

'format units of the surface area
dArea1 = oDoc.UnitsOfMeasure.ConvertUnits(dArea1, "cm cm", "ft ft")

'format the number
Dim dAreaShort1 As Double
dAreaShort1 = Round(dArea1, 3 )

'get the start face of extrusion1
Dim oStartFace As Face
oStartFace = oExtrude1.StartFaces.Item(1)

'get area of face
Dim dArea2 As Double
dArea2 = Round(oStartFace.Evaluator.Area ,4)

'format units of the surface area
dArea2 = oDoc.UnitsOfMeasure.ConvertUnits(dArea2, "cm cm", "ft ft")

'format the number
Dim dAreaShort2 As Double
dAreaShort2 = Round(dArea2, 3 )

'return results
MessageBox.Show("The end face surface area is: " & dAreaShort1 & " ft^2" & vbLf & _
"And the start face surface area is: " & dAreaShort2 & " ft^2" , "iLogic")

 

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

Post to forums  

Autodesk Design & Make Report