I am using vb.net for Inventor API programming.And my need is to change the material using api and get the updated volume.I coded like this.

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()

but in property the material name was change but it didn't update the mass and volume. any one know why?

没有正确的解决方案

其他提示

You have to find the material and assign it to the component definition.

        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;
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top