Community
style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
"Patrick de Stobbeleir" <
href="mailto:pdsa@hotmail.com">pdsa@hotmail.com> wrote in message
href="news:63032EBA4CB9EAD622F4832E777B8F4F@in.WebX.maYIadrTaRb">news:63032EBA4CB9EAD622F4832E777......
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
"CD Smith" <> I need a little
href="mailto:carl@cadvantage.net">
size=2>carl@cadvantage.net> wrote in
message
href="news:ECDCB4713B014572CA5496B21ADF5E07@in.WebX.maYIadrTaRb">
face=Arial
size=2>news:ECD...
face=Arial size=2>...
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
>
>
style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
"Patrick de Stobbeleir" <
href="mailto:pdsa@hotmail.com">pdsa@hotmail.com> wrote in message
href="news:63032EBA4CB9EAD622F4832E777B8F4F@in.WebX.maYIadrTaRb">news:63032EBA4CB9EAD622F4832E777......
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
"CD Smith" <> I need a little
href="mailto:carl@cadvantage.net">
size=2>carl@cadvantage.net> wrote in
message
href="news:ECDCB4713B014572CA5496B21ADF5E07@in.WebX.maYIadrTaRb">
face=Arial
size=2>news:ECD...
face=Arial size=2>...
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.