i am just copying macros whichever fit my needs....and i came across a vba view rep code...can this be converted to a positional representation?
the structure would be the same, top level assembly and sub assembly 1, 2, 3, etc...i need to set the posrep of the sub assemblies..
any help is much appreciated...
thanks joel..
the following code is the closest i could reference however it is based on view rep...
Dim aDoc As AssemblyDocument
Set aDoc = ThisApplication.ActiveDocument
Dim oAsmCompDef As ComponentDefinition
Dim oCompOcc As Inventor.ComponentOccurrence
Set oAsmCompDef = aDoc.ComponentDefinition
For Each oCompOcc In oAsmCompDef.Occurrences
If oCompOcc.Visible = True Then
If oCompOcc.DefinitionDocumentType = kAssemblyDocumentObject Then
Call oCompOcc.SetDesignViewRepresentation("DH - MB", , True)
Else
End If
Else
End If
On Error Resume Next
Next
Put the following in your code between the for each loop:
try
Dim a As Inventor.PositionalRepresentation a.SetPositionalRepresentationOverride(ocompocc,"name of Pos"
Catch ex As Exception
end try
then you need to know the name of the PosRepresentation to be set as "Name of Pos"
Regards,
Arthur Knoors
Autodesk Affiliations:
Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:Drawing List!|Toggle Drawing Sheet!|Workplane Resize!|Drawing View Locker!|Multi Sheet to Mono Sheet!|Drawing Weld Symbols!|Drawing View Label Align!|Open From Balloon!|Model State Lock!
Posts and Ideas:Dimension Component!|Partlist Export!|Derive I-properties!|Vault Prompts Via API!|Vault Handbook/Manual!|Drawing Toggle Sheets!|Vault Defer Update!
! For administrative reasons, please mark a "Solution as solved" when the issue is solved !
it doesn't accept the code...its red
"set a.SetPositionalRepresentationOverride(oCompOcc, "Free Drag - SW")"
this one seems to work but on the top level assembly only....how can this be modified to go sub assembly 1, 2, 3,..etc...
' get the current assembly
Dim oDoc As AssemblyDocument
Set oDoc = ThisApplication.ActiveDocument
' get AssemblyComponentDefinition
Dim AssemblyDef As AssemblyComponentDefinition
Set AssemblyDef = oDoc.ComponentDefinition
' get the component occurence
Dim oCompOcc As Inventor.ComponentOccurrence
' get Manager of Representations
Dim dViewRepMgr As RepresentationsManager
Set dViewRepMgr = AssemblyDef.RepresentationsManager
' get pos rep settings
Set dViewRep = dViewRepMgr.PositionalRepresentations.Item(3)
' activate the first view
dViewRep.Activate
Regards,
Arthur Knoors
Autodesk Affiliations:
Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:Drawing List!|Toggle Drawing Sheet!|Workplane Resize!|Drawing View Locker!|Multi Sheet to Mono Sheet!|Drawing Weld Symbols!|Drawing View Label Align!|Open From Balloon!|Model State Lock!
Posts and Ideas:Dimension Component!|Partlist Export!|Derive I-properties!|Vault Prompts Via API!|Vault Handbook/Manual!|Drawing Toggle Sheets!|Vault Defer Update!
! For administrative reasons, please mark a "Solution as solved" when the issue is solved !
here..as what i understand..
"a.SetPositionalRepresentationOverride(ocompocc,"Free Drag - SW")
Catch ex As Exception
end try"
the above lines appears in red.....seems not accepted by VBA..?
Public Sub testposrepsubassy()
Dim aDoc As AssemblyDocument
Set aDoc = ThisApplication.ActiveDocument
Dim oAsmCompDef As ComponentDefinition
Dim oCompOcc As Inventor.ComponentOccurrence
Set oAsmCompDef = aDoc.ComponentDefinition
For Each oCompOcc In oAsmCompDef.Occurrences
If oCompOcc.Visible = True Then
If oCompOcc.DefinitionDocumentType = kAssemblyDocumentObject Then
'Call oCompOcc.SetDesignViewRepresentation("Free Drag - SW", , True)
'*****************
try
Dim a As Inventor.PositionalRepresentation
a.SetPositionalRepresentationOverride(ocompocc,"Free Drag - SW")
Catch ex As Exception
end try
'*****************
Else
End If
Else
End If
On Error Resume Next
Next
End Sub
Can't find what you're looking for? Ask the community or share your knowledge.