- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I am making a complex illogic code... one thing that I want it to do it to add a colour to all view on the file.
for now it work on part(Ipt)...
It change colour on all the view .. my problem is that I want it that o go want to the view that you where working on before running the code... I have a other code that do this ... but it is for assembly only ..... so I can´t just copy past that part of the code....but it work for assembly ... that I will have to make my code later paint a colour as well
the code below create some standard view .. and go back to the view I work on ... how to I go back to the active view before I run the code on a part?
' get Manager of Representations
Dim dViewRepMgr As RepresentationsManager
dViewRepMgr = oAsmCompDef.RepresentationsManager
'Get active Representation View
Dim dViewRep As DesignViewRepresentation
dViewRep = dViewRepMgr.ActiveDesignViewRepresentation
'Dim AktivVeiw As String
'AktivVeiw = "Master"
'MessageBox.Show(AktivVeiw, "Info")
Try
'create a list of view reps
For Each oViewRep In oViewReps
NameList.Add(oViewRep.Name)
Next
'check names
'-----------------------------------Tilføje Asset view ----------------------
'If NameList.Contains("Asset") = False Then
''set View Rep active
'oViewRep = oAsmCompDef.RepresentationsManager.DesignViewRepresentations.Add("Asset")
'StandardViewCreate = True
'MessageBox.Show("Veiw Asset was created", "Info")
'End If
'-----------------------------------Tilføje Asset view ----------------------
If NameList.Contains("Complete") = False Then
'set View Rep active
oViewRep = oAsmCompDef.RepresentationsManager.DesignViewRepresentations.Add("Complete")
StandardViewCreate = True
'MessageBox.Show("Veiw Complete was created", "Info")
End If
If NameList.Contains("Simplified") = False Then
oViewRep = oAsmCompDef.RepresentationsManager.DesignViewRepresentations.Add("Simplified")
StandardViewCreate = True
'MessageBox.Show("Veiw Simplified was created", "Info")
End If
If StandardViewCreate = True Then
'Return to orginal aktiv veiw
dViewRep.Activate
'Tilføj denne nedestående kode igen hvis man ønsker en beked om at de sandard views er blevet lavet
'MessageBox.Show("Standard veiws was created", "Info")
StandardViewCreate = False
End If
Catch
End Try
End If
Catch
End Try
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hoping that below iLogic code may be useful to activate active view. Before adding views, collect the active name view and then activate it after your task.
Dim doc As AssemblyDocument doc = ThisApplication.ActiveDocument ' get AssemblyComponentDefinition Dim AssemblyDef As AssemblyComponentDefinition AssemblyDef = doc.ComponentDefinition ' get Manager of Representations Dim dViewRepMgr As RepresentationsManager dViewRepMgr = AssemblyDef.RepresentationsManager Dim dViewRep As DesignViewRepresentation dViewRep = dViewRepMgr.ActiveDesignViewRepresentation Dim oName As String oName = dViewRep.Name ' get the first Representation view dViewRep = dViewRepMgr.DesignViewRepresentations.Item(oName) ' activate the first view dViewRep.Activate
Thanks and regards,
CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Look at your code it looks a lot like the Code i use for assambly ... the problem is that it will not work on a part (IPT file).
can you rewrite it for a part/ipt file ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Try this,
Dim doc As PartDocument doc = ThisApplication.ActiveDocument ' get AssemblyComponentDefinition Dim partDef As PartComponentDefinition partDef = doc.ComponentDefinition ' get Manager of Representations Dim dViewRepMgr As RepresentationsManager dViewRepMgr = partDef.RepresentationsManager Dim dViewRep As DesignViewRepresentation dViewRep = dViewRepMgr.ActiveDesignViewRepresentation Dim oName As String oName = dViewRep.Name ' get the first Representation view dViewRep = dViewRepMgr.DesignViewRepresentations.Item(oName) ' activate the first view dViewRep.Activate
Thanks and regards,
CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
it seems to work ... now I just need to find a right way to intergrade it into my other code thanks