INVENTOR I PROPERTY CUSTOMIZATION

INVENTOR I PROPERTY CUSTOMIZATION

Anonymous
Not applicable
469 Views
1 Reply
Message 1 of 2

INVENTOR I PROPERTY CUSTOMIZATION

Anonymous
Not applicable

Dear Sir

We have modelled a Simple Plate of a desired Length,Breadth and Height and now we can calculate the Raw Volume(Stock).

So now there are some Opeartions that are been done on the Plate and then we calculate the Finished Volume.

Also whenever I change the Length,Breadth or the Height it automatically calculates the Volumes and it shows as a BOM in Drawings.

However I would like to import Both the Volumes(Raw Volume and Finished Volume) and show it in the Bill of Materials in the Idw Format and Ideally calculate the Ratio between the

two Volumes which needs to be integrated in the ERP as a whole.

Whenever I change the Volumes the Ratio gets adjusted Automatically.I have attached the Sample BOM.

Can we Customize the same in Inventor.

Kindly suggest how to go ahead with it.

Can we use it as a Custom I Property and import it and show it in Idw Format.

0 Likes
470 Views
1 Reply
Reply (1)
Message 2 of 2

wayne.brill
Collaborator
Collaborator

Hi,

 

This VBA example moves the end of the part after the first feature. It then gets the Volume and puts that value in an iProperty. After this the end of the part is moved to the end of the features and the volume is retrieved again and saved to a different iProperty. Maybe an approach like this will meet your requirement.

 

'Update From the example in the API help
Public Sub UpdateVolume()
    ' Get the active part document.
    Dim invPartDoc As PartDocument
    Set invPartDoc = ThisApplication.ActiveDocument

   ' Get the custom property set.
    Dim invCustomPropertySet As PropertySet
    Set invCustomPropertySet = invPartDoc.PropertySets.Item("Inventor User Defined Properties")

    Dim oFeat As ExtrudeFeature
    Set oFeat = invPartDoc.ComponentDefinition.Features.ExtrudeFeatures(1)
    
    Call oFeat.SetEndOfPart(False)

    ' Get the volume of the part. This will be returned in
    ' cubic centimeters.
    Dim dVolume As Double
    dVolume = invPartDoc.ComponentDefinition.MassProperties.Volume

    ' Get the UnitsOfMeasure object which is used to do unit conversions.
    Dim oUOM As UnitsOfMeasure
    Set oUOM = invPartDoc.UnitsOfMeasure

    ' Convert the volume to the current document units.
    Dim strVolume As String
    strVolume = oUOM.GetStringFromValue(dVolume, oUOM.GetStringFromType(oUOM.LengthUnits) & "^3")
 
    Call AddiProps("OriginalVolume", strVolume, invCustomPropertySet)
    
    Call invPartDoc.ComponentDefinition.SetEndOfPartToTopOrBottom(False)
    
    dVolume = invPartDoc.ComponentDefinition.MassProperties.Volume

    ' Convert the volume to the current document units.
    strVolume = oUOM.GetStringFromValue(dVolume, oUOM.GetStringFromType(oUOM.LengthUnits) & "^3")
 
    Call AddiProps("FinalVolume", strVolume, invCustomPropertySet)
    
End Sub

Public Function AddiProps(iPropName As String, Vol As String, invCustomPropertySet As PropertySet)
    
    ' Attempt to get an existing custom property named "Volume".
    On Error Resume Next
    Dim myProperty As Property
    Set myProperty = invCustomPropertySet.Item(iPropName)
    
    If Err.Number <> 0 Then
        ' Failed to get the property, which means it doesn't exist
        ' so we'll create it.
        Call invCustomPropertySet.Add(Vol, iPropName)
    Else
        ' Got the property so update the value.
        myProperty.Value = Vol
    End If
  
End Function

 

 

Thanks,

Wayne



Wayne Brill
Developer Technical Services
Autodesk Developer Network

0 Likes