Inventor General Discussion

Inventor General Discussion

Reply
Valued Contributor
dclunie
Posts: 70
Registered: ‎03-26-2008
Message 1 of 3 (675 Views)

vb-ilogic rule

675 Views, 2 Replies
10-01-2012 10:27 AM

Hi all

 

I am looking for a rule to remove all colour overides in all assemblys and .ipts

 

When we merged all our data across to inventor 2013 all our visual styles and materials where all over the place and has still to be resolve by autodesk.However when we update our parts via stlyes and stds some .ipts have a colour overide assigned to them and we have to go into each part individually to remove the colour overide.

 

Is there a rule that will work at top level and look down stream and remove all colour overides in all .ipts and iams without editing all individually

 

Removing apperance overides does not work for this

 

any thought's on this would be appreciated

 

Dave

*Expert Elite*
Curtis_Waguespack
Posts: 2,874
Registered: ‎03-08-2006
Message 2 of 3 (658 Views)

Re: ilogic rule: Remove color overrides, strip color overrides, solid colors

10-01-2012 01:20 PM in reply to: dclunie

Hi dclunie,

 

This should get you started. I didn't have much time to test it thoroughly, so you might encounter issues with sub assemblies, design view reps, etc. But this should get the ball rolling.

 

Also note that you might get better results with programming type questions on the customization forum:

http://forums.autodesk.com/t5/Autodesk-Inventor-Customization/bd-p/120

 

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

 

Dim oAsmCompDef As AssemblyComponentDefinition
oAsmCompDef = ThisApplication.ActiveDocument.ComponentDefinition

'set Master view rep active
Dim oViewRep As DesignViewRepresentation
oViewRep =oAsmCompDef.RepresentationsManager.DesignViewRepresentations.Item("Master")
oViewRep.Activate

'Define the open document
Dim openDoc As Document
openDoc = ThisDoc.Document

'Look at all of the files referenced in the open document
Dim docFile As Document
For Each docFile In openDoc.AllReferencedDocuments                
'format  file name                   
Dim FNamePos As Long
FNamePos = InStrRev(docFile.FullFileName, "\", -1)                        
Dim docFName As String
docFName = Right(docFile.FullFileName, Len(docFile.FullFileName) - FNamePos)

    Dim oCompDef As Inventor.PartComponentDefinition
    oCompDef = docFile.ComponentDefinition

    'Iterate through all features
    Dim oFeature As PartFeature
    For Each oFeature In oCompDef.Features
    'Set the render style to be "As Body"
    oFeature.SetRenderStyle(37125)      
    Next
         
    'Iterate through all solids
    For Each Solid In oCompDef.SurfaceBodies
    'Set the render style to be "As Part"
    Solid.SetRenderStyle(37121, True)      
        'Iterate through all faces.
        Dim oFace As Face
        For Each oFace In Solid.Faces
        ' Set the render style to be "As Feature"
        oFace.SetRenderStyle(37122)
        Next      
    Next

Next

iLogicVb.UpdateWhenDone = True

 



  solution.png  Did you find this reply helpful ? If so please use the Accept as Solution or  Kudos button below.





*Expert Elite*
Curtis_Waguespack
Posts: 2,874
Registered: ‎03-08-2006
Message 3 of 3 (644 Views)

Re: ilogic rule: Remove color overrides, strip color overrides, solid colors

10-01-2012 03:55 PM in reply to: Curtis_Waguespack

Hi dclunie,

 

I just noticed the code below does not handle sub assemblies well at all, and errors out when the top level assembly contains a subassembly. So just be aware of that.

 

Also I'd left in a few extra lines of code that were un-needed, I've removed them in the version posted below.

 

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

 

Dim oAsmCompDef As AssemblyComponentDefinition
oAsmCompDef = ThisApplication.ActiveDocument.ComponentDefinition

'set Master view rep active
Dim oViewRep As DesignViewRepresentation
oViewRep =oAsmCompDef.RepresentationsManager.DesignViewRepresentations.Item("Master")
oViewRep.Activate

'Define the open document
Dim openDoc As Document
openDoc = ThisDoc.Document

'Look at all of the files referenced in the open document
Dim docFile As Document
For Each docFile In openDoc.AllReferencedDocuments                

    Dim oCompDef As Inventor.PartComponentDefinition
    oCompDef = docFile.ComponentDefinition

    'Iterate through all features
    Dim oFeature As PartFeature
    For Each oFeature In oCompDef.Features
    'Set the render style to be "As Body"
    oFeature.SetRenderStyle(37125)      
    Next
         
    'Iterate through all solids
    For Each Solid In oCompDef.SurfaceBodies
    'Set the render style to be "As Part"
    Solid.SetRenderStyle(37121, True)      
        'Iterate through all faces.
        Dim oFace As Face
        For Each oFace In Solid.Faces
        ' Set the render style to be "As Feature"
        oFace.SetRenderStyle(37122)
        Next      
    Next

Next

iLogicVb.UpdateWhenDone = True


  solution.png  Did you find this reply helpful ? If so please use the Accept as Solution or  Kudos button below.





Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.