我正在使用vb.net进行Inventor API编程。我需要使用api更改材料并获取更新的卷。我这样编码。
Dim oDoc As PartDocument
oDoc = inventorApp.ActiveDocument
Dim oDTProps As PropertySet
oDTProps = oDoc.PropertySets.Item("{32853F0F-3444-11d1-9E93-0060B03C1CA6}")
Dim oDesignerProp As Inventor.Property
oDesignerProp = oDTProps.ItemByPropId( _
PropertiesForDesignTrackingPropertiesEnum.kMaterialDesignTrackingProperties)
oDesignerProp = oDTProps.Item("Material")
oDesignerProp.Value = "Titanium"
oDoc.Update()
但在属性中,材料名称已更改,但未更新质量和体积。 谁知道为什么?
答案 0 :(得分:1)
您必须找到材料并将其分配给组件定义。
var app =(Application) System.Runtime.InteropServices.Marshal.GetActiveObject("Inventor.Application");
var doc = app.ActiveDocument;
var partDoc = (PartDocument)doc;
var compDef = partDoc.ComponentDefinition;
var mass1 = compDef.MassProperties.Mass;
var mat =
(from Material material in partDoc.Materials
where material.Name == "Titan"
select material).First();
partDoc.ComponentDefinition.Material = mat;
if (mat.StyleLocation == StyleLocationEnum.kLibraryStyleLocation)
mat.ConvertToLocal();
var mass2 = compDef.MassProperties.Mass;