Clear Overide on all Conponent(first level ) on assambly

Clear Overide on all Conponent(first level ) on assambly

Darkforce_the_ilogic_guy
Advisor Advisor
473 Views
2 Replies
Message 1 of 3

Clear Overide on all Conponent(first level ) on assambly

Darkforce_the_ilogic_guy
Advisor
Advisor

I have this code .. I keep getting an error .. that I want the code to

do is to cleal override the component in the assembly on all view... I have a code that do the same for part... that work ... I have a code the can add an colour to the component or part ... but I like to make the code needed to remove the colour again after add them to the part and assembly ... only thing that I can not get to work jet is the assembly  clearsoverride.. see the code I have so far below

 

 

 Dim oAsmCompDef 'As AssemblyComponentDefinition

 
oAsmCompDef = ThisApplication.ActiveDocument.ComponentDefinition
 
 Dim oViewReps As DesignViewRepresentations
oViewReps = oAsmCompDef.RepresentationsManager.DesignViewRepresentations


'define view rep
Dim oViewRep As DesignViewRepresentation


Dim NumberOfView = oViewReps.Count
' get Manager of Representations

 Dim dViewRepMgr As RepresentationsManager
 dViewRepMgr = oAsmCompDef.RepresentationsManager

 'Get active Representation View
 Dim dViewRep As DesignViewRepresentation
 dViewRep = dViewRepMgr.ActiveDesignViewRepresentation

 
 

For i = 1 To NumberOfView
 If iProperties.Value("Custom", "Surface") = "Raw" Or iProperties.Value("Custom", "Surface") = "Galv." Or iProperties.Value("Custom", "Surface") = "Colour 1" Or iProperties.Value("Custom", "Surface") = "Colour 2" Or iProperties.Value("Custom", "Surface") = "RAL 5003" Or iProperties.Value("Custom", "Surface") = "RAL 9010" Or iProperties.Value("Custom", "Surface") = "RAL 1028" Or iProperties.Value("Custom", "Surface") = "RAL 9005"  Or iProperties.Value("Custom", "Surface") = "EG-Galv" Or iProperties.Value("Custom", "Surface") = "HDG-Galv"  Then

oViewReps.Item(i).Activate
End If

'---------------------
Dim oAsmDoc As AssemblyDocument
oAsmDoc = ThisDoc.Document
Dim oAsmCompDef As AssemblyComponentDefinition
oAsmCompDef = oAsmDoc.ComponentDefinition

Dim oOccurrence As ComponentOccurrence
For Each oOccurrence In oAsmCompDef.Occurrences


oAsmCompDef.ClearAppearanceOverrides(oOccurrence.name)
 
 iLogicVb.UpdateWhenDone = True

Next

'-------------------------
iLogicVb.UpdateWhenDone = True

Next

 

 

 

0 Likes
Accepted solutions (2)
474 Views
2 Replies
Replies (2)
Message 2 of 3

chandra.shekar.g
Autodesk Support
Autodesk Support
Accepted solution

@Darkforce_the_ilogic_guy,

 

Actually, method AssemblyComponentDefinition.ClearAppearanceOverrides( [AppearanceOverrideObjects] As Variant ) would accept input parameter as object collection. Try below changes in your iLogic code.

 

Dim oAsmCompDef 'As AssemblyComponentDefinition

 
oAsmCompDef = ThisApplication.ActiveDocument.ComponentDefinition
 
 Dim oViewReps As DesignViewRepresentations
oViewReps = oAsmCompDef.RepresentationsManager.DesignViewRepresentations


'define view rep
Dim oViewRep As DesignViewRepresentation


Dim NumberOfView = oViewReps.Count
' get Manager of Representations

 Dim dViewRepMgr As RepresentationsManager
 dViewRepMgr = oAsmCompDef.RepresentationsManager

 'Get active Representation View
 Dim dViewRep As DesignViewRepresentation
 dViewRep = dViewRepMgr.ActiveDesignViewRepresentation

 
 

For i = 1 To NumberOfView
 If iProperties.Value("Custom", "Surface") = "Raw" Or iProperties.Value("Custom", "Surface") = "Galv." Or iProperties.Value("Custom", "Surface") = "Colour 1" Or iProperties.Value("Custom", "Surface") = "Colour 2" Or iProperties.Value("Custom", "Surface") = "RAL 5003" Or iProperties.Value("Custom", "Surface") = "RAL 9010" Or iProperties.Value("Custom", "Surface") = "RAL 1028" Or iProperties.Value("Custom", "Surface") = "RAL 9005"  Or iProperties.Value("Custom", "Surface") = "EG-Galv" Or iProperties.Value("Custom", "Surface") = "HDG-Galv"  Then

oViewReps.Item(i).Activate
End If

'---------------------
Dim oAsmDoc As AssemblyDocument
oAsmDoc = ThisDoc.Document
Dim oAsmCompDef As AssemblyComponentDefinition
oAsmCompDef = oAsmDoc.ComponentDefinition

Dim objColl As ObjectCollection 
objColl = ThisApplication.TransientObjects.CreateObjectCollection 

Dim oOccurrence As ComponentOccurrence
For Each oOccurrence In oAsmCompDef.Occurrences

	Call objColl.Add(oOccurrence)

 
 iLogicVb.UpdateWhenDone = True

Next
oAsmCompDef.ClearAppearanceOverrides(objColl)
'-------------------------
iLogicVb.UpdateWhenDone = True

Next

 Thanks and regards,


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network



Message 3 of 3

Accepted solution

It almost work I did have to delete 2 line of the code... but after that it look like it will work

 

Dim oAsmCompDef 'As AssemblyComponentDefinition

 
oAsmCompDef = ThisApplication.ActiveDocument.ComponentDefinition
 
 Dim oViewReps As DesignViewRepresentations
oViewReps = oAsmCompDef.RepresentationsManager.DesignViewRepresentations


'define view rep
Dim oViewRep As DesignViewRepresentation


Dim NumberOfView = oViewReps.Count
' get Manager of Representations

 Dim dViewRepMgr As RepresentationsManager
 dViewRepMgr = oAsmCompDef.RepresentationsManager

 'Get active Representation View
 Dim dViewRep As DesignViewRepresentation
 dViewRep = dViewRepMgr.ActiveDesignViewRepresentation

 
 

For i = 1 To NumberOfView
 If iProperties.Value("Custom", "Surface") = "Raw" Or iProperties.Value("Custom", "Surface") = "Galv." Or iProperties.Value("Custom", "Surface") = "Colour 1" Or iProperties.Value("Custom", "Surface") = "Colour 2" Or iProperties.Value("Custom", "Surface") = "RAL 5003" Or iProperties.Value("Custom", "Surface") = "RAL 9010" Or iProperties.Value("Custom", "Surface") = "RAL 1028" Or iProperties.Value("Custom", "Surface") = "RAL 9005"  Or iProperties.Value("Custom", "Surface") = "EG-Galv" Or iProperties.Value("Custom", "Surface") = "HDG-Galv"  Then

oViewReps.Item(i).Activate
End If

'---------------------
Dim oAsmDoc As AssemblyDocument
oAsmDoc = ThisDoc.Document
Dim oAsmCompDef As AssemblyComponentDefinition
oAsmCompDef = oAsmDoc.ComponentDefinition

Dim objColl As ObjectCollection 
objColl = ThisApplication.TransientObjects.CreateObjectCollection 

Dim oOccurrence As ComponentOccurrence
For Each oOccurrence In oAsmCompDef.Occurrences

	Call objColl.Add(oOccurrence)

 
 iLogicVb.UpdateWhenDone = True

Next
oAsmCompDef.ClearAppearanceOverrides(objColl)
'-------------------------
iLogicVb.UpdateWhenDone = True

Next

 

0 Likes