Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.
david_alcalde6P6BN
316 Views, 4 Replies

Control LevelOfDetail with positions and Ilogic?

Hi everyone, I need help, 

I have learn a little bit of ilogic by myself and I managed with the forum and googles help to write (or copy and modify bits and combine) some macros to make my life easier, but I am lost now.

I have been trying for a couple of days to link the position of my assemblies with the level of detail and I can't make it work.

I have several positions called LVL1, LVL2.... and so on and levels of detail called the same, the asembly moves to the LVL1 position and I am trying that the LevelOfDetail changes automatically accordingly but it seems just impossible.

I have been searching the forum and found some code, but nothing seems to work properly. (Some rules work, but the trigger does not)

Dim oAsmCompDef As AssemblyComponentDefinition
oAsmCompDef = ThisApplication.ActiveDocument.ComponentDefinition
	If oAsmCompDef.RepresentationsManager.ActiveLevelOfDetailRepresentation.Name = "LVL1" Then
oAsmCompDef.RepresentationsManager.PositionalRepresentations.Item("LVL1").Activate
	Else If oAsmCompDef.RepresentationsManager.ActiveLevelOfDetailRepresentation.Name = "LVL2" Then
oAsmCompDef.RepresentationsManager.PositionalRepresentations.Item("LVL2").Activate
	Else If oAsmCompDef.RepresentationsManager.ActiveLevelOfDetailRepresentation.Name = "LVL3" Then
oAsmCompDef.RepresentationsManager.PositionalRepresentations.Item("LVL3").Activate
	End If

 

    Dim oAsmDoc As AssemblyDocument
     oAsmDoc = ThisApplication.ActiveDocument
    
    Dim oAsmDef As AssemblyComponentDefinition
     oAsmDef = ThisApplication.ActiveDocument.ComponentDefinition
    
    Dim oC As ComponentOccurrences
     oC = oAsmDef.Occurrences
    
    Dim oOcc As ComponentOccurrence
    
    Dim pos As Integer
    pos = 1
    Dim oPosRep As PositionalRepresentation
     oPosRep = oAsmDef.RepresentationsManager.PositionalRepresentations("LVL1")
    For Each oOcc In oC
         If pos = 1 Then
            Call oPosRep.SetPositionalRepresentationOverride(oOcc, "LVL1")
            pos = 0
        Else
            Call oPosRep.RemovePositionalRepresentationOverride(oOcc)
            pos = 1
        End If
    Next


The first code works, (it does it's thing the other way round, I wish to activate the position to make the level of detail change, but I will be happy with that if there is no way to make it the other way) but it does not trigger automatically, I have to run the rule manually; I tried with events and nothing, then found something called "OnActivatePositionalRepresentation" wich seemed promising but I know very little of ilogic and it seems I cannot make it work.
The secong I didn't manage it to make it work at all but was somewhere in the forum as a solution...


Thanks to everyone, hope you can help me