Message 1 of 11
Substitute part for custom LOD
Not applicable
10-17-2009
07:55 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
The question to Inventor API experts.
Inventor 2009 SP2
Let’s assume we have an assembly model
with two custom LODs named “State1” and “State2” and
we have to create programmatically two substitute parts
for each of custom LOD (as it is possible in UI from a dialog).
I tried to modify DerivedAssemblyDefinition but failed.
From on-line Help for DerivedAssemblyComponents:
{code}
Public Function CreateDefinition( _
ByVal FullDocumentName As String _
) As DerivedAssemblyDefinition
Parameters
FullDocumentName
String that specifies the full document name
of the assembly document to create the definition for.
If ONLY the FullFileName is specified, the master
document within the assembly file is opened.
{code}
This is a very strange comment because method
has only one parameter (filename).
In which way I can specify NOT ONLY FullFileName
(e.g. custom LOD)?
I failed to change read/write property
ActiveLevelOfDetailRepresentation of the just created
DerivedAssemblyDefinition object.
May be the only way to create DerivedAssemblyDefinition
for a custom LOD is using of the property
InclusionOption = kDerivedExcludeAll in conjunction
with kDerivedIndividualDefined to add unsuppressed
occurrences one by one?
What is the recommended solution?
Any help will be appreciated.
-------------------------
Here is my test sub.
{code}
Sub CreateSubstitutePart()
Dim AssyFilename As String '' source assy file name
AssyFilename = "C:\Temp\TestAssy.iam"
Dim PartFileName As String '' file name for substitute part
PartFileName = "C:\Temp\TestAssy_State1.ipt"
' create new part document (hidden mode)
Dim oPartDoc As PartDocument
oPartDoc = ThisApplication.Documents.Add( _
DocumentTypeEnum.kPartDocumentObject, _
ThisApplication.FileManager.GetTemplateFile( _
DocumentTypeEnum.kPartDocumentObject), _
False)
Dim oPartCompDef As PartComponentDefinition
oPartCompDef = oPartDoc.ComponentDefinition
' Create Derived Assembly Definition for the file AssyFilename
Dim oDerivedAssyDef As DerivedAssemblyDefinition
oDerivedAssyDef = oPartCompDef.ReferenceComponents. _
DerivedAssemblyComponents.CreateDefinition(AssyFilename)
~~~~ OPTIONS ~~~~
'Scale factor
oDerivedAssyDef.ScaleFactor = 1
'RMM flag
oDerivedAssyDef.ReducedMemoryMode = True
'Include all available components
oDerivedAssyDef.InclusionOption = _
DerivedComponentOptionEnum.kDerivedIncludeAll
'------ this doesn’t work ----------
'define nedded LOD - here is error message
oDerivedAssyDef.ActiveLevelOfDetailRepresentation = "State1"
'-----------------------------------
'create derived component
Call oPartCompDef.ReferenceComponents. _
DerivedAssemblyComponents.Add(oDerivedAssyDef)
oPartDoc.IsSubstitutePart = True ''substitute flag
Call oPartDoc.SaveAs(PartFileName, False)
Call oPartDoc.Close()
End Sub
{code}
Inventor 2009 SP2
Let’s assume we have an assembly model
with two custom LODs named “State1” and “State2” and
we have to create programmatically two substitute parts
for each of custom LOD (as it is possible in UI from a dialog).
I tried to modify DerivedAssemblyDefinition but failed.
From on-line Help for DerivedAssemblyComponents:
{code}
Public Function CreateDefinition( _
ByVal FullDocumentName As String _
) As DerivedAssemblyDefinition
Parameters
FullDocumentName
String that specifies the full document name
of the assembly document to create the definition for.
If ONLY the FullFileName is specified, the master
document within the assembly file is opened.
{code}
This is a very strange comment because method
has only one parameter (filename).
In which way I can specify NOT ONLY FullFileName
(e.g. custom LOD)?
I failed to change read/write property
ActiveLevelOfDetailRepresentation of the just created
DerivedAssemblyDefinition object.
May be the only way to create DerivedAssemblyDefinition
for a custom LOD is using of the property
InclusionOption = kDerivedExcludeAll in conjunction
with kDerivedIndividualDefined to add unsuppressed
occurrences one by one?
What is the recommended solution?
Any help will be appreciated.
-------------------------
Here is my test sub.
{code}
Sub CreateSubstitutePart()
Dim AssyFilename As String '' source assy file name
AssyFilename = "C:\Temp\TestAssy.iam"
Dim PartFileName As String '' file name for substitute part
PartFileName = "C:\Temp\TestAssy_State1.ipt"
' create new part document (hidden mode)
Dim oPartDoc As PartDocument
oPartDoc = ThisApplication.Documents.Add( _
DocumentTypeEnum.kPartDocumentObject, _
ThisApplication.FileManager.GetTemplateFile( _
DocumentTypeEnum.kPartDocumentObject), _
False)
Dim oPartCompDef As PartComponentDefinition
oPartCompDef = oPartDoc.ComponentDefinition
' Create Derived Assembly Definition for the file AssyFilename
Dim oDerivedAssyDef As DerivedAssemblyDefinition
oDerivedAssyDef = oPartCompDef.ReferenceComponents. _
DerivedAssemblyComponents.CreateDefinition(AssyFilename)
~~~~ OPTIONS ~~~~
'Scale factor
oDerivedAssyDef.ScaleFactor = 1
'RMM flag
oDerivedAssyDef.ReducedMemoryMode = True
'Include all available components
oDerivedAssyDef.InclusionOption = _
DerivedComponentOptionEnum.kDerivedIncludeAll
'------ this doesn’t work ----------
'define nedded LOD - here is error message
oDerivedAssyDef.ActiveLevelOfDetailRepresentation = "State1"
'-----------------------------------
'create derived component
Call oPartCompDef.ReferenceComponents. _
DerivedAssemblyComponents.Add(oDerivedAssyDef)
oPartDoc.IsSubstitutePart = True ''substitute flag
Call oPartDoc.SaveAs(PartFileName, False)
Call oPartDoc.Close()
End Sub
{code}