ilogic - Select all visible compnents and change appearance, welds to differ one

ilogic - Select all visible compnents and change appearance, welds to differ one

steveh3
Advisor Advisor
1,205 Views
5 Replies
Message 1 of 6

ilogic - Select all visible compnents and change appearance, welds to differ one

steveh3
Advisor
Advisor

Gang...

Somewhat new to ilogic.

Attempting to select all visible components in an assembly and change appearance to a particular color.

Then I want to change the Welds to a different color.

appearnce.png

Searched quite a bit and not finding anything.

 

Any help? 

Thanks in advance,

 

Steve H.

Steve Hilvers
Inventor Certified User / Vault Professional Influencer
0 Likes
Accepted solutions (1)
1,206 Views
5 Replies
Replies (5)
Message 2 of 6

JelteDeJong
Mentor
Mentor
Accepted solution

try this iLogic code:

Dim doc As AssemblyDocument = ThisApplication.ActiveDocument
' set your collors/assets here Dim assetOccurrences As Asset = doc.Assets.Item("Chestnut") Dim assetWelds As Asset = doc.Assets.Item("Brass - Satin") For Each occ As ComponentOccurrence In doc.ComponentDefinition.Occurrences occ.Appearance = assetOccurrences Next Dim weldDef As WeldmentComponentDefinition = doc.ComponentDefinition weldDef.WeldBeadAppearance = assetWelds

Make sure that the assets (colors) are in the part. (if the are only in the AssetLibraries then they need to be copyed to the part)

Jelte de Jong
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


Blog: hjalte.nl - github.com

0 Likes
Message 3 of 6

steveh3
Advisor
Advisor

Thanks Jelte...

Inserted your code recommendation into my logic and getting an error...

'Define current document

Dim odoc As Document
Dim oCompDef As ComponentDefinition
odoc = ThisApplication.ActiveDocument
oCompDef = odoc.ComponentDefinition

Dim oviewrep As DesignViewRepresentation
Try
oCompDef.RepresentationsManager.DesignViewRepresentations.Item("Hi-Lited Welds").Activate
Catch
 oviewrep = oCompDef.RepresentationsManager.DesignViewRepresentations.Add("Hi-Lited Welds")
 'Activate new View Rep
 oViewRep.activate
End Try

Dim doc As AssemblyDocument = ThisApplication.ActiveDocument
' set your collors/assets here
Dim assetOccurrences As Asset = doc.Assets.Item("Chestnut")
Dim assetWelds As Asset = doc.Assets.Item("Brass - Satin")

For Each occ As ComponentOccurrence In doc.ComponentDefinition.Occurrences
    occ.Appearance = assetOccurrences
Next

Dim weldDef As WeldmentComponentDefinition = doc.ComponentDefinition
weldDef.WeldBeadAppearance = assetWelds

'Turn off ALL object visibility
ThisApplication.ActiveDocument.ObjectVisibility.AllWorkfeatures = False
ThisApplication.ActiveDocument.ObjectVisibility.ConstructionSurfaces = False
ThisApplication.ActiveDocument.ObjectVisibility.Sketches = False
ThisApplication.ActiveDocument.ObjectVisibility.Sketches3D = False
ThisApplication.ActiveDocument.ObjectVisibility.SketchDimensions = False
ThisApplication.ActiveDocument.ObjectVisibility.Annotations3D = False
If odoc.DocumentType = kAssemblyDocumentObject Then	
  ThisApplication.ActiveDocument.ObjectVisibility.WeldmentSymbols = True 
  ThisApplication.ActiveDocument.ObjectVisibility.Welds = True
End If 

 

Think it has something to do with lines that set the colors...but I'm not good enough to decipher.

Again...Thanks so far. Getting closer 🙂 

Steve Hilvers
Inventor Certified User / Vault Professional Influencer
0 Likes
Message 4 of 6

chandra.shekar.g
Autodesk Support
Autodesk Support

@steveh3,

 

Hoping that suggestions in the below forum discussion may be helpful.

 

https://forums.autodesk.com/t5/inventor-customization/change-part-color-in-sub-assembly-from-top-ass...

 

Thanks and regards,


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network



0 Likes
Message 5 of 6

steveh3
Advisor
Advisor

Thanks for all the help thus far.

Getting back into this code. I thought I had it running, but getting an error. Have to manually set colors first. After I do that and delete the view rep out...then ilogic will run.

 

Here's a video showing what is happening....

 

https://autode.sk/2K6xL00

 

Best,

 

Steve Hilvers

Steve Hilvers
Inventor Certified User / Vault Professional Influencer
0 Likes
Message 6 of 6

steveh3
Advisor
Advisor

bump, bump, bump....😁

Steve Hilvers
Inventor Certified User / Vault Professional Influencer
0 Likes