문제

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