How to buy
Privacy | Do not sell or share my personal information | Cookie preferences | Report noncompliance | Terms of use | Legal | © 2025 Autodesk Inc. All rights reserved
Hello,
Does anybody know if it is possible in Inventor 2016 to colorize all surfaces in one color from an ipt with ilogic?
Solved! Go to Solution.
Hi @mgeurts,
Are you after having each part in a different color - this was an idea floating around on the idea station and somebody had made a vba macro - if this is what you are after https://forums.autodesk.com/t5/inventor-ideas/visual-style-every-part-with-different-color/idi-p/871...
Thanks for your reply but it is not what I'm looking for.
An ipt as raw casting is machined in an iam. The machined surfaces must be red so with real painting it will be obvious which surfaces to paint and which not.
Now I make the material from the ipt red and then manually all surfaces gray through Properties, so in the iam the machined surfaces come out red again.
To give manually all surfaces a different color is time consuming, therefore the question if it is possible to do this in 2016 with ilogic.
Hi @mgeurts
Do I understand correctly that you want to color every face in a part from an iLogic rule within the part (In part environment)
Try something like this:
Dim oDoc As PartDocument = ThisDoc.Document Dim oStyle As RenderStyle = oDoc.RenderStyles("Red") For Each oSolid As SurfaceBody In oDoc.ComponentDefinition.SurfaceBodies For Each oFace As Face In oSolid.Faces oFace.SetRenderStyle(kOverrideRenderStyle, oStyle) Next Next
That will color every face in the part red.
Jhoel Forshav Download my free Inventor Addin - Hole Projector
LinkedIn | Ideas | Contributions | Blog posts | Website
Hi, @JhoelForshav
Thanks for your reply.
Yes, that's exactly what I'm looking for but I'm complete noob at this.
Anyway managed to run it but got an error:
what's the error? @mgeurts
Jhoel Forshav Download my free Inventor Addin - Hole Projector
LinkedIn | Ideas | Contributions | Blog posts | Website
I didn't realize that pics were not uploaded:
Maybe you dont have the renderstyle "Red"...
Does this work then? 🙂
Dim oDoc As PartDocument = ThisDoc.Document Dim oRenderStyles As RenderStyles = oDoc.RenderStyles Dim oName As String = "Red_Color" Dim styleExists As Boolean = False Dim myStyle As RenderStyle For Each oRenderStyle As RenderStyle In oRenderStyles If oRenderStyle.Name = oName styleExists = True myStyle = oRenderStyle Exit For End If Next If Not styleExists myStyle = oRenderStyles.Add(oName) myStyle.SetAmbientColor(255, 0, 0) myStyle.SetDiffuseColor(255, 0, 0) End If For Each oSurfBod As SurfaceBody In oDoc.ComponentDefinition.SurfaceBodies For Each oFace As Face In oSurfBod.Faces oFace.SetRenderStyle(kOverrideRenderStyle, myStyle) Next Next
Jhoel Forshav Download my free Inventor Addin - Hole Projector
LinkedIn | Ideas | Contributions | Blog posts | Website
Now I got this reporting:
The first one made me check if I have all service packs. Autodesk Desktop App is telling I'm up to date but in Inventor I don't see any SP's installed:
Tried to install SP1 doesn't do anything and when I ty to install SP2 it says to install SP1.
Considering ilogic: I opened Add Rule and pasted the code, after OK I got the error.
ipt attached.
Maybe it doesn't get the StyleSourceTypeEnum correct with just kOverrideRenderStyle...
Could try changing it to this:
Dim oDoc As PartDocument = ThisDoc.Document Dim oRenderStyles As RenderStyles = oDoc.RenderStyles Dim oName As String = "Red_Color" Dim styleExists As Boolean = False Dim myStyle As RenderStyle For Each oRenderStyle As RenderStyle In oRenderStyles If oRenderStyle.Name = oName styleExists = True myStyle = oRenderStyle Exit For End If Next If Not styleExists myStyle = oRenderStyles.Add(oName) myStyle.SetAmbientColor(255, 0, 0) myStyle.SetDiffuseColor(255, 0, 0) End If For Each oSurfBod As SurfaceBody In oDoc.ComponentDefinition.SurfaceBodies For Each oFace As Face In oSurfBod.Faces oFace.SetRenderStyle(StyleSourceTypeEnum.kOverrideRenderStyle, myStyle) Next Next
Or this:
Dim oDoc As PartDocument = ThisDoc.Document Dim oRenderStyles As RenderStyles = oDoc.RenderStyles Dim oName As String = "Red_Color" Dim styleExists As Boolean = False Dim myStyle As RenderStyle For Each oRenderStyle As RenderStyle In oRenderStyles If oRenderStyle.Name = oName styleExists = True myStyle = oRenderStyle Exit For End If Next If Not styleExists myStyle = oRenderStyles.Add(oName) myStyle.SetAmbientColor(255, 0, 0) myStyle.SetDiffuseColor(255, 0, 0) End If For Each oSurfBod As SurfaceBody In oDoc.ComponentDefinition.SurfaceBodies For Each oFace As Face In oSurfBod.Faces oFace.SetRenderStyle(37123, myStyle) Next Next
It works for me in 2020 either way - See screencast. I can't test in 2016 though...
Jhoel Forshav Download my free Inventor Addin - Hole Projector
LinkedIn | Ideas | Contributions | Blog posts | Website
Good morning!
Both codes are working. Many thanks for your effort.
Have a nice day
Happy to help! I guess that was the problem with the first code i posted also then...
So something like this probably works as well?
Dim oDoc As PartDocument = ThisDoc.Document Dim oStyle As RenderStyle = oDoc.RenderStyles("Red") For Each oSolid As SurfaceBody In oDoc.ComponentDefinition.SurfaceBodies For Each oFace As Face In oSolid.Faces oFace.SetRenderStyle(StyleSourceTypeEnum.kOverrideRenderStyle, oStyle) Next Next
Jhoel Forshav Download my free Inventor Addin - Hole Projector
LinkedIn | Ideas | Contributions | Blog posts | Website
Yes, this one works also.
Thanks again!
How to buy
Privacy | Do not sell or share my personal information | Cookie preferences | Report noncompliance | Terms of use | Legal | © 2025 Autodesk Inc. All rights reserved
Type a product name