Hello, I am trying to create an iLogic code that can create an associative view representation in an assembly. Right now I am stuck on just getting the view representations created in each component of my assembly. I continue to get the error Public member 'RepresentationsManager' on type 'ComponentOccurence' not found. Any help would be greatly appreciated.
Dim oDoc As Document Dim oCompDef As ComponentDefinition oDoc = ThisApplication.ActiveDocument oCompDef = oDoc.ComponentDefinition For Each oOcc In oCompDef.Occurrences If Component.IsActive(oOcc.Name) If oOcc.DefinitionDocumentType = DocumentTypeEnum.kPartDocumentObject Dim oviewrep As DesignViewRepresentation Try MsgBox("Got Here") oOcc.SetDesignViewRepresentation("Custom",, True) Catch MsgBox("Got Here") oviewrep = oOcc.RepresentationsManager.DesignViewRepresentations.Add("Custom",True) oviewrep.activate End Try End If End If Next iLogicVb.UpdateWhenDone = True
Solved! Go to Solution.
Solved by WCrihfield. Go to Solution.
Hi @David.Berken. The RepresentationsManager is a property of either the PartComponentDefinition or the AssemblyComponentDefinition objects. So from the component's perspective this would be under the oOcc.Definition, but it's a bit tricky, because that returns a generic ComponentDefinition object which doesn't have the RepresentationsManager as one of its properties. So you could check the Type of the oOcc.Definition using the TypeOf operator, then create a variable of the needed specific Type and set oOcc.Definition as its value. Then you could access this properly, with support from the Intellisense type system (pop-up suggestions & info).
Here is some example iLogic code along the same lines as a pointer:
'Set or Create DesignViewRepresentations In Assembly Components
Dim oADoc As AssemblyDocument = ThisApplication.ActiveDocument
oADef = oADoc.ComponentDefinition
For Each oOcc As ComponentOccurrence In oADef.Occurrences
If Not oOcc.Suppressed Then
If TypeOf oOcc.Definition Is PartComponentDefinition Then
'If oOcc.IsAssociativeToDesignViewRepresentation Then
'Dim oPDoc As PartDocument = oOcc.Definition.Document
'oRepsMgr = oPDoc.ComponentDefinition.RepresentationsManager
Dim oPDef As PartComponentDefinition = oOcc.Definition
oDVRepName = "My DVRep"
oDVReps = oPDef.RepresentationsManager.DesignViewRepresentations
For Each oDVRep As DesignViewRepresentation In oDVReps
If oDVRep.Name = oDVRepName Then
'Found it'
oOcc.SetDesignViewRepresentation(oDVRepName, , True)
End If
Next
End If
End If
Next
If this solved your problem, or answered your question, please click ACCEPT SOLUTION.
Or, if this helped you, please click (LIKE or KUDOS) 👍.
If you want and have time, I would appreciate your Vote(s) for My IDEAS :light_bulb: or you can Explore My CONTRIBUTIONS
Wesley Crihfield
(Not an Autodesk Employee)
Can't find what you're looking for? Ask the community or share your knowledge.