How to get tensile strength of material by ilogoc

How to get tensile strength of material by ilogoc

王承之pmhker
Advisor Advisor
695 Views
3 Replies
Message 1 of 4

How to get tensile strength of material by ilogoc

王承之pmhker
Advisor
Advisor

Here is my code, which can obtain all other physical properties except for tensile strength. I don't know where the mistake lies, I hope to get help, thank you

 

Dim oDoc As PartDocument = ThisDoc.Document

Dim MatName As String = oDoc.ComponentDefinition.Material.Name
Dim PR As Double = oDoc.ComponentDefinition.Material.PoissonsRatio
Dim Den As Double = oDoc.ComponentDefinition.Material.Density
Dim YS As Double = oDoc.ComponentDefinition.Material.YieldStrength
'Dim TS As Double = oDoc.ComponentDefinition.Material.TensileStrength

MsgBox("材质 " & MatName & " 的泊松比: " & PR &"/ 密度: " & Den &"/ 屈服强度: " & YS & “/ 抗拉强度:” & TS)


If my post answers your question, please click the "Accept as Solution" button. This helps everyone find answers more quickly!
如果我的回帖解决了您的问题,请点击 "接受为解决方案" 按钮. 这可以帮助其他人更快的找到解决方案!


王 承之
Autodesk AGN [Inventor 俱乐部] Leader
Inventor Club | Bilibili


AGN L    EESignature

0 Likes
Accepted solutions (2)
696 Views
3 Replies
Replies (3)
Message 2 of 4

bradeneuropeArthur
Mentor
Mentor
Accepted solution

Use this instead:

 

Dim oDoc As PartDocument = ThisDoc.Document

Dim MatName As String = oDoc.ComponentDefinition.Material.Name
Dim PR As Double = oDoc.ComponentDefinition.Material.PoissonsRatio
Dim Den As Double = oDoc.ComponentDefinition.Material.Density
Dim YS As Double = oDoc.ComponentDefinition.Material.YieldStrength
Dim TS As Double = oDoc.ComponentDefinition.Material.UltimateTensileStrength

In addition to this, this way of coding is better to understand.

First step of coding is to declare every variable..

 

Dim m As Material = oDoc.ComponentDefinition.Material
will give you these results: m.UltimateTensileStrength m.Density m.Name m.PoissonsRatio m.YieldStrength m.ExternalMaterialId m.LinearExpansion m.InternalName m.SpecificHeat m.ThermalConductivity m.UltimateTensileStrength m.YoungsModulus

with this as result:

Dim oDoc As PartDocument = ThisDoc.Document
Dim m As Material = oDoc.ComponentDefinition.Material
Dim MatName As String = m.Name
Dim PR As Double = m.PoissonsRatio
Dim Den As Double = m.Density
Dim YS As Double = m.YieldStrength
Dim TS As Double = m.UltimateTensileStrength

MsgBox("材质 " & MatName & " 的泊松比: " & PR &"/ 密度: " & Den &"/ 屈服强度: " & YS & “/ 抗拉强度:” & TS)

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

Message 3 of 4

WCrihfield
Mentor
Mentor
Accepted solution

Just showing the newer way to do this, since the code shown in both of those posts is using objects and properties that have been outdated / obsolete since 2013, and I am not sure how much longer they will be supported.  You can review the following online help link for more details about that.

Consistent Materials (Materials and Appearances) 

 

The newer objects and properties do seem to be a little more complicated to use, so I do not blame anyone for wanting to keep using the older methods for as long as they continue to work.  Since the newer Asset object (and the derived MaterialAsset) is now used for representing materials, appearances, and the physical properties of materials, they do not have a lot of public, logically named properties for each of the individual pieces of information that they can possibly store (there are a ton of them), all detailed information is now stored within AssetValue type objects, within the Asset.  And the AssetValue type is just a base type for 9 other derived, and more specific sub types, for the different types of values they can have.  Some can even have multiple values.  Each one has a 'Name' and a 'DisplayName', with the 'Name' being the language stable way to go, but has a less obvious value.

 

The example below is using the 'Name' property, so that it will be language stable.

Dim oDoc As PartDocument = ThisDoc.Document

Dim Mat As MaterialAsset = oDoc.ActiveMaterial
Dim Phys As Asset = Mat.PhysicalPropertiesAsset

Dim MatName As String = Mat.Name

Dim FloatAV_ForPoissonsRatio As FloatAssetValue = Phys.Item("structural_Poisson_ratio")
Dim PR As Double = FloatAV_ForPoissonsRatio.Value

Dim FloatAV_ForDensity As FloatAssetValue = Phys.Item("structural_Density")
Dim Den As Double = FloatAV_ForDensity.Value

Dim FloatAV_ForYieldStrength As FloatAssetValue = Phys.Item("structural_Minimum_yield_stress")
Dim YS As Double = FloatAV_ForYieldStrength.Value

Dim FloatAV_ForTensileStrength As FloatAssetValue = Phys.Item("structural_Minimum_tensile_strength")
Dim TS As Double = FloatAV_ForTensileStrength.Value

MsgBox("材质 " & MatName & " 的泊松比: " & PR &"/ 密度: " & Den &"/ 屈服强度: " & YS & “/ 抗拉强度:” & TS)

 

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 4 of 4

bradeneuropeArthur
Mentor
Mentor

@WCrihfield , Indeed you may be right that this seems to be a bit more complicated, but I always mention in general that in many cases "the easiest is not the most practical solution"!

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

0 Likes