Hi
İ use inventor 2011
i designed my assembly and assign color each one Part and Subassembly
i want to that parts' lines and subassembly's lines of my assembly is color as model properties when i generate creat view and poject view in Drawing
also while create view, are there selection "as model" for lines of part
exam :
in assembly
1-Assembly
1-1 part (color is red)
in dravwing
1-Assembly
1-1 parts' line color is red
Solved! Go to Solution.
Solved by брайян_ивашкевич. Go to Solution.
I don't know a way of doing this automatically In Inventor.
You might want to think of manually using layers to assign certain colors to certain parts.
A good idea might be to post your question on the Inventor API newsgroup.They might be able to help you much better, better than I can.
I am not a good coder but I was able to throw a macro togerther in a couple of minutes that sets the part color in the drawing to either green,blue or red when either of these 3 colors is used in the part document.
The only condition is that you need to define in your drawing template 3 layers with name "Layer red", "Layer green" and "Layer blue".
'==========================================
Sub change_color()
Dim odoc As DrawingDocument
Set odoc = ThisApplication.ActiveDocument
Dim opartdoc As ComponentDefinition
Dim opdoc As PartDocument
Dim osheet As Sheet
Dim oview As DrawingView
Dim oedge As DrawingCurve
Dim olayer As Layer
Dim redlayer, bluelayer, greenlayer As Layer
For Each olayer In odoc.StylesManager.Layers
If olayer.Name = "Layer red" Then Set redlayer = olayer
If olayer.Name = "Layer blue" Then Set bluelayer = olayer
If olayer.Name = "Layer green" Then Set greenlayer = olayer
Next olayer
For Each osheet In odoc.Sheets
For Each oview In osheet.DrawingViews
For Each oedge In oview.DrawingCurves
Set opartdoc = oedge.ModelGeometry.Parent.Parent.Definition
Set opdoc = opartdoc.Document
Select Case opdoc.ActiveRenderStyle.Name
Case "Red"
oedge.Color = redlayer.Color
Case "Blue"
oedge.Color = bluelayer.Color
Case "Green"
oedge.Color = greenlayer.Color
End Select
Next oedge
Next oview
Next osheet
End Sub
'==================================
Bob
Dim redlayer, bluelayer, greenlayer As Layer
This dimensions "greenlayer" as type Layer, but "redlayer" and "bluelayer" are Variants. Obviously, this still works due to VB's late-binding ability, but it's poor programming practice and is a common mistake. Instead, use
Dim redlayer As Layer, bluelayer As Layer, greenlayer As Layer
Thanks for your correction.
Bob
Do You think it's possible to write macro that sets line colors of part from material style ?
One of my clients need something like this - to set line color in part files and after this create drawing and every part will then have other line colors (according to material style)
Jakub