Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Part Volume

2 REPLIES 2
Reply
Message 1 of 3
Anonymous
394 Views, 2 Replies

Part Volume

Anonymous
Not applicable
I need a little help taking care of a client who needs to be able to add the
part volume to his drawing information (title block). He makes plastic parts
and would like this information to help with costing information. He would
like for the information to be parametrically linked to the model so that
the updates are automatic as his design matures.

Any help would be appreciated

Carl Smith
CADvantage, Inc
888-891-1700
0 Likes

Part Volume

I need a little help taking care of a client who needs to be able to add the
part volume to his drawing information (title block). He makes plastic parts
and would like this information to help with costing information. He would
like for the information to be parametrically linked to the model so that
the updates are automatic as his design matures.

Any help would be appreciated

Carl Smith
CADvantage, Inc
888-891-1700
2 REPLIES 2
Message 2 of 3
Anonymous
in reply to: Anonymous

Anonymous
Not applicable
Carl,

 

I'm looking at this small problem to and I think
5.3 will be the easy answer, because it's possible to create macro that is
executed automatically when the part is saved (AutoSave macro)

 

In release 5 you need to make a add-in to get the
same functionality

 

This basic VBA example should run on both versions,
it only works when the part is opened as a single document (watch
out for word-wraps!!)

 

Public Sub AutoSave()

 

    Dim oCompDef As
ComponentDefinition
    Dim TotalMass, TotalVolume As
Double
    Dim oProp As
Property
    Dim oPropSet As
PropertySet

    On Error Resume Next
   
Set oCompDef =
ThisApplication.ActiveDocument.ComponentDefinition
   

    oCompDef.MassProperties.Accuracy =
k_High
    TotalMass =
oCompDef.MassProperties.Mass
    TotalVolume =
oCompDef.MassProperties.Volume
   
    'Add
a custom property "TotalMass" with the Part Mass
    Set
oPropSet =
ThisApplication.ActiveDocument.PropertySets("{D5CDD505-2E9C-101B-9397-08002B2CF9AE}")
   
oPropSet.Item("Totalmass").Delete
    'The check of unit type
must be enhanced to all the possibilities
    If
ThisApplication.ActiveDocument.UnitsOfMeasure.MassUnits = kKilogramMassUnits
Then
        Call
oPropSet.Add(Format((TotalMass / 1000), "#0.####") & " kg",
"Totalmass")
   
Else
        Call
oPropSet.Add(Format((TotalMass / 453.59237), "#0.####") & " lb",
"Totalmass")
    End If
   

    'Add a custom property "TotalVolume" with the Part
Volume
    Set oPropSet =
ThisApplication.ActiveDocument.PropertySets("{D5CDD505-2E9C-101B-9397-08002B2CF9AE}")
   
oPropSet.Item("TotalVolume").Delete
    'The check of unit
type must be enhanced to all the possibilities
    If
ThisApplication.ActiveDocument.UnitsOfMeasure.LengthUnits =
kMillimeterLengthUnits Then
        Call
oPropSet.Add(Format(TotalVolume, "#0.0####") & " mm^3",
"TotalVolume")
   
Else
        Call
oPropSet.Add(Format(TotalVolume, "#0.0####") & " in^3",
"TotalVolume")
    End If

 

   
    'Uses
i.e. the Cost Center value to the Part Mass as a workaround because the a model
custom property can't be transferred to the drawing
    Set
oProp =
ThisApplication.ActiveDocument.PropertySets("{32853F0F-3444-11D1-9E93-0060B03C1CA6}").ItemByPropId(9)
   
'The check of unit type must be enhanced to all the
possibilities
    If
ThisApplication.ActiveDocument.UnitsOfMeasure.MassUnits = kKilogramMassUnits
Then
        oProp.Value =
(Format((TotalMass / 1000), "#0.####") & " kg")
   
Else
        oProp.Value =
(Format((TotalMass / 453.59237), "#0.####") & "lb")
   
End If
   
    'Uses i.e. the Authority
value to the Part Volume as a workaround because the a model custom property
can't be transferred to the drawing
    Set oProp =
ThisApplication.ActiveDocument.PropertySets("{32853F0F-3444-11D1-9E93-0060B03C1CA6}").ItemByPropId(43)
   
'The check of unit type must be enhanced to all the
possibilities
    If
ThisApplication.ActiveDocument.UnitsOfMeasure.LengthUnits =
kMillimeterLengthUnits Then
       
oProp.Value = (Format(TotalVolume, "#0.0####") & "
mm^3")
    Else
       
oProp.Value = (Format(TotalVolume, "#0.0####") & "
in^3")
    End If

 

End Sub

 

> I need a little
help taking care of a client who needs to be able to add the
> part volume
to his drawing information (title block). He makes plastic parts
> and
would like this information to help with costing information. He would
>
like for the information to be parametrically linked to the model so
that
> the updates are automatic as his design matures.
>
>
Any help would be appreciated
>
> Carl Smith
> CADvantage,
Inc
> 888-891-1700
>
>
0 Likes

Carl,

 

I'm looking at this small problem to and I think
5.3 will be the easy answer, because it's possible to create macro that is
executed automatically when the part is saved (AutoSave macro)

 

In release 5 you need to make a add-in to get the
same functionality

 

This basic VBA example should run on both versions,
it only works when the part is opened as a single document (watch
out for word-wraps!!)

 

Public Sub AutoSave()

 

    Dim oCompDef As
ComponentDefinition
    Dim TotalMass, TotalVolume As
Double
    Dim oProp As
Property
    Dim oPropSet As
PropertySet

    On Error Resume Next
   
Set oCompDef =
ThisApplication.ActiveDocument.ComponentDefinition
   

    oCompDef.MassProperties.Accuracy =
k_High
    TotalMass =
oCompDef.MassProperties.Mass
    TotalVolume =
oCompDef.MassProperties.Volume
   
    'Add
a custom property "TotalMass" with the Part Mass
    Set
oPropSet =
ThisApplication.ActiveDocument.PropertySets("{D5CDD505-2E9C-101B-9397-08002B2CF9AE}")
   
oPropSet.Item("Totalmass").Delete
    'The check of unit type
must be enhanced to all the possibilities
    If
ThisApplication.ActiveDocument.UnitsOfMeasure.MassUnits = kKilogramMassUnits
Then
        Call
oPropSet.Add(Format((TotalMass / 1000), "#0.####") & " kg",
"Totalmass")
   
Else
        Call
oPropSet.Add(Format((TotalMass / 453.59237), "#0.####") & " lb",
"Totalmass")
    End If
   

    'Add a custom property "TotalVolume" with the Part
Volume
    Set oPropSet =
ThisApplication.ActiveDocument.PropertySets("{D5CDD505-2E9C-101B-9397-08002B2CF9AE}")
   
oPropSet.Item("TotalVolume").Delete
    'The check of unit
type must be enhanced to all the possibilities
    If
ThisApplication.ActiveDocument.UnitsOfMeasure.LengthUnits =
kMillimeterLengthUnits Then
        Call
oPropSet.Add(Format(TotalVolume, "#0.0####") & " mm^3",
"TotalVolume")
   
Else
        Call
oPropSet.Add(Format(TotalVolume, "#0.0####") & " in^3",
"TotalVolume")
    End If

 

   
    'Uses
i.e. the Cost Center value to the Part Mass as a workaround because the a model
custom property can't be transferred to the drawing
    Set
oProp =
ThisApplication.ActiveDocument.PropertySets("{32853F0F-3444-11D1-9E93-0060B03C1CA6}").ItemByPropId(9)
   
'The check of unit type must be enhanced to all the
possibilities
    If
ThisApplication.ActiveDocument.UnitsOfMeasure.MassUnits = kKilogramMassUnits
Then
        oProp.Value =
(Format((TotalMass / 1000), "#0.####") & " kg")
   
Else
        oProp.Value =
(Format((TotalMass / 453.59237), "#0.####") & "lb")
   
End If
   
    'Uses i.e. the Authority
value to the Part Volume as a workaround because the a model custom property
can't be transferred to the drawing
    Set oProp =
ThisApplication.ActiveDocument.PropertySets("{32853F0F-3444-11D1-9E93-0060B03C1CA6}").ItemByPropId(43)
   
'The check of unit type must be enhanced to all the
possibilities
    If
ThisApplication.ActiveDocument.UnitsOfMeasure.LengthUnits =
kMillimeterLengthUnits Then
       
oProp.Value = (Format(TotalVolume, "#0.0####") & "
mm^3")
    Else
       
oProp.Value = (Format(TotalVolume, "#0.0####") & "
in^3")
    End If

 

End Sub

 

> I need a little
help taking care of a client who needs to be able to add the
> part volume
to his drawing information (title block). He makes plastic parts
> and
would like this information to help with costing information. He would
>
like for the information to be parametrically linked to the model so
that
> the updates are automatic as his design matures.
>
>
Any help would be appreciated
>
> Carl Smith
> CADvantage,
Inc
> 888-891-1700
>
>
Message 3 of 3
Anonymous
in reply to: Anonymous

Anonymous
Not applicable
Thanks Patrick


style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">

Carl,

 

I'm looking at this small problem to and I think
5.3 will be the easy answer, because it's possible to create macro that is
executed automatically when the part is saved (AutoSave macro)

 

In release 5 you need to make a add-in to get the
same functionality

 

This basic VBA example should run on both
versions, it only works when the part is opened as a single
document (watch out for word-wraps!!)

 

Public Sub AutoSave()

 

    Dim oCompDef As
ComponentDefinition
    Dim TotalMass, TotalVolume As
Double
    Dim oProp As
Property
    Dim oPropSet As
PropertySet

    On Error Resume
Next
    Set oCompDef =
ThisApplication.ActiveDocument.ComponentDefinition
   

    oCompDef.MassProperties.Accuracy =
k_High
    TotalMass =
oCompDef.MassProperties.Mass
    TotalVolume =
oCompDef.MassProperties.Volume
   
   
'Add a custom property "TotalMass" with the Part Mass
   
Set oPropSet =
ThisApplication.ActiveDocument.PropertySets("{D5CDD505-2E9C-101B-9397-08002B2CF9AE}")
   
oPropSet.Item("Totalmass").Delete
    'The check of unit
type must be enhanced to all the possibilities
    If
ThisApplication.ActiveDocument.UnitsOfMeasure.MassUnits = kKilogramMassUnits
Then
        Call
oPropSet.Add(Format((TotalMass / 1000), "#0.####") & " kg",
"Totalmass")
   
Else
        Call
oPropSet.Add(Format((TotalMass / 453.59237), "#0.####") & " lb",
"Totalmass")
    End If
   

    'Add a custom property "TotalVolume" with the Part
Volume
    Set oPropSet =
ThisApplication.ActiveDocument.PropertySets("{D5CDD505-2E9C-101B-9397-08002B2CF9AE}")
   
oPropSet.Item("TotalVolume").Delete
    'The check of unit
type must be enhanced to all the possibilities
    If
ThisApplication.ActiveDocument.UnitsOfMeasure.LengthUnits =
kMillimeterLengthUnits Then
        Call
oPropSet.Add(Format(TotalVolume, "#0.0####") & " mm^3",
"TotalVolume")
   
Else
        Call
oPropSet.Add(Format(TotalVolume, "#0.0####") & " in^3",
"TotalVolume")
    End If

 

   
    'Uses
i.e. the Cost Center value to the Part Mass as a workaround because the a
model custom property can't be transferred to the
drawing
    Set oProp =
ThisApplication.ActiveDocument.PropertySets("{32853F0F-3444-11D1-9E93-0060B03C1CA6}").ItemByPropId(9)
   
'The check of unit type must be enhanced to all the
possibilities
    If
ThisApplication.ActiveDocument.UnitsOfMeasure.MassUnits = kKilogramMassUnits
Then
        oProp.Value =
(Format((TotalMass / 1000), "#0.####") & " kg")
   
Else
        oProp.Value =
(Format((TotalMass / 453.59237), "#0.####") & "lb")
   
End If
   
    'Uses i.e. the Authority
value to the Part Volume as a workaround because the a model custom property
can't be transferred to the drawing
    Set oProp =
ThisApplication.ActiveDocument.PropertySets("{32853F0F-3444-11D1-9E93-0060B03C1CA6}").ItemByPropId(43)
   
'The check of unit type must be enhanced to all the
possibilities
    If
ThisApplication.ActiveDocument.UnitsOfMeasure.LengthUnits =
kMillimeterLengthUnits Then
       
oProp.Value = (Format(TotalVolume, "#0.0####") & "
mm^3")
   
Else
        oProp.Value =
(Format(TotalVolume, "#0.0####") & " in^3")
    End
If

 

End Sub

 

> I need a little
help taking care of a client who needs to be able to add the
> part
volume to his drawing information (title block). He makes plastic
parts
> and would like this information to help with costing
information. He would
> like for the information to be parametrically
linked to the model so that
> the updates are automatic as his design
matures.
>
> Any help would be appreciated
>
> Carl
Smith
> CADvantage, Inc
> 888-891-1700
>
>
0 Likes

Thanks Patrick


style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">

Carl,

 

I'm looking at this small problem to and I think
5.3 will be the easy answer, because it's possible to create macro that is
executed automatically when the part is saved (AutoSave macro)

 

In release 5 you need to make a add-in to get the
same functionality

 

This basic VBA example should run on both
versions, it only works when the part is opened as a single
document (watch out for word-wraps!!)

 

Public Sub AutoSave()

 

    Dim oCompDef As
ComponentDefinition
    Dim TotalMass, TotalVolume As
Double
    Dim oProp As
Property
    Dim oPropSet As
PropertySet

    On Error Resume
Next
    Set oCompDef =
ThisApplication.ActiveDocument.ComponentDefinition
   

    oCompDef.MassProperties.Accuracy =
k_High
    TotalMass =
oCompDef.MassProperties.Mass
    TotalVolume =
oCompDef.MassProperties.Volume
   
   
'Add a custom property "TotalMass" with the Part Mass
   
Set oPropSet =
ThisApplication.ActiveDocument.PropertySets("{D5CDD505-2E9C-101B-9397-08002B2CF9AE}")
   
oPropSet.Item("Totalmass").Delete
    'The check of unit
type must be enhanced to all the possibilities
    If
ThisApplication.ActiveDocument.UnitsOfMeasure.MassUnits = kKilogramMassUnits
Then
        Call
oPropSet.Add(Format((TotalMass / 1000), "#0.####") & " kg",
"Totalmass")
   
Else
        Call
oPropSet.Add(Format((TotalMass / 453.59237), "#0.####") & " lb",
"Totalmass")
    End If
   

    'Add a custom property "TotalVolume" with the Part
Volume
    Set oPropSet =
ThisApplication.ActiveDocument.PropertySets("{D5CDD505-2E9C-101B-9397-08002B2CF9AE}")
   
oPropSet.Item("TotalVolume").Delete
    'The check of unit
type must be enhanced to all the possibilities
    If
ThisApplication.ActiveDocument.UnitsOfMeasure.LengthUnits =
kMillimeterLengthUnits Then
        Call
oPropSet.Add(Format(TotalVolume, "#0.0####") & " mm^3",
"TotalVolume")
   
Else
        Call
oPropSet.Add(Format(TotalVolume, "#0.0####") & " in^3",
"TotalVolume")
    End If

 

   
    'Uses
i.e. the Cost Center value to the Part Mass as a workaround because the a
model custom property can't be transferred to the
drawing
    Set oProp =
ThisApplication.ActiveDocument.PropertySets("{32853F0F-3444-11D1-9E93-0060B03C1CA6}").ItemByPropId(9)
   
'The check of unit type must be enhanced to all the
possibilities
    If
ThisApplication.ActiveDocument.UnitsOfMeasure.MassUnits = kKilogramMassUnits
Then
        oProp.Value =
(Format((TotalMass / 1000), "#0.####") & " kg")
   
Else
        oProp.Value =
(Format((TotalMass / 453.59237), "#0.####") & "lb")
   
End If
   
    'Uses i.e. the Authority
value to the Part Volume as a workaround because the a model custom property
can't be transferred to the drawing
    Set oProp =
ThisApplication.ActiveDocument.PropertySets("{32853F0F-3444-11D1-9E93-0060B03C1CA6}").ItemByPropId(43)
   
'The check of unit type must be enhanced to all the
possibilities
    If
ThisApplication.ActiveDocument.UnitsOfMeasure.LengthUnits =
kMillimeterLengthUnits Then
       
oProp.Value = (Format(TotalVolume, "#0.0####") & "
mm^3")
   
Else
        oProp.Value =
(Format(TotalVolume, "#0.0####") & " in^3")
    End
If

 

End Sub

 

> I need a little
help taking care of a client who needs to be able to add the
> part
volume to his drawing information (title block). He makes plastic
parts
> and would like this information to help with costing
information. He would
> like for the information to be parametrically
linked to the model so that
> the updates are automatic as his design
matures.
>
> Any help would be appreciated
>
> Carl
Smith
> CADvantage, Inc
> 888-891-1700
>
>

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report