Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Picking up the solid volume by name

4 REPLIES 4
SOLVED
Reply
Message 1 of 5
manu.marjanen
489 Views, 4 Replies

Picking up the solid volume by name

How do i get only "solid3" volume, by using iLogic?

manumarjanen_0-1642142483026.png

 

4 REPLIES 4
Message 2 of 5

You can read volume of all individual bodies, or one body accessed by its index (order) or its name

 

Dim part As PartDocument = ThisDoc.Document

'Get volume of individual bodies
Dim precisionPercent As Double = 0.01
For Each oBody As SurfaceBody In part.ComponentDefinition.SurfaceBodies
    Logger.Debug(String.Format("{0}{2}{1}", oBody.Name, oBody.Volume(precisionPercent), vbTab))
Next

'Get volume for individual body by its name
Dim bodyName As String = part.ComponentDefinition.SurfaceBodies(1).Name

Dim bodyByName As SurfaceBody = part.ComponentDefinition.SurfaceBodies.OfType(Of SurfaceBody).FirstOrDefault(Function(b) b.Name = bodyName)
If bodyByName Is Nothing Then
    Logger.Warn("Body not found")
Else
    Logger.Info(bodyByName.Volume(precisionPercent))
End If
Message 3 of 5



 

 

Message 4 of 5

Can the "solid3" volume data be transferred to the parameter table?

 

manumarjanen_0-1642153265941.png

 

Message 5 of 5

Dim part As PartDocument = ThisDoc.Document

'Get volume of individual bodies
Dim precisionPercent As Double = 0.01
Dim bodyName As String = "Solid3"
Dim solidVolume As Double = 0

'Get volume for individual body by its name
Dim bodyByName As SurfaceBody = part.ComponentDefinition.SurfaceBodies.OfType(Of SurfaceBody).FirstOrDefault(Function(b) b.Name = bodyName)
If bodyByName Is Nothing Then
    Logger.Warn("Body not found")
Else
	solidVolume = bodyByName.Volume(precisionPercent)
    Logger.Info(solidVolume)
End If
solidVolume *= 1000 'Convert [cm3] to [dm3]([l])
Parameter("Solid3_Volume") = solidVolume

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

Post to forums  

Technology Administrators


Autodesk Design & Make Report