Change view back to aktive view before running ilogic(Add colur to all View)

Change view back to aktive view before running ilogic(Add colur to all View)

Darkforce_the_ilogic_guy
Advisor Advisor
610 Views
4 Replies
Message 1 of 5

Change view back to aktive view before running ilogic(Add colur to all View)

Darkforce_the_ilogic_guy
Advisor
Advisor

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
 

0 Likes
Accepted solutions (1)
611 Views
4 Replies
Replies (4)
Message 2 of 5

chandra.shekar.g
Autodesk Support
Autodesk Support

@Darkforce_the_ilogic_guy ,

 

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



Message 3 of 5

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  ?

0 Likes
Message 4 of 5

chandra.shekar.g
Autodesk Support
Autodesk Support
Accepted solution

@Darkforce_the_ilogic_guy,

 

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



Message 5 of 5

it seems to work ... now I just need to find a right way to intergrade it into my other code thanks

0 Likes