Assembly Macro Color (keeping component properties)
Assembly Macro Color (keeping component properties)
(OP)
So I am interested in coloring a part inside of an assembly using the 'component properties'. However I cannot find how to do this using a macro.
I am interested in doing this because I am exporting the file in VRML format and it will only recognize color if the color is specified in the assembly (rather than the part).
The macros that I have seen can color a particular part, but this color will continue throughout all the other (similar) parts that are inserted into the assembly.
I want to color each individual part a different color on the assembly level and I cannot color the part using the feature properties or face panels to get this effect.
Could someone point me to some code or to a function call inside of solidworks... Im using 2003
Thanks
I am interested in doing this because I am exporting the file in VRML format and it will only recognize color if the color is specified in the assembly (rather than the part).
The macros that I have seen can color a particular part, but this color will continue throughout all the other (similar) parts that are inserted into the assembly.
I want to color each individual part a different color on the assembly level and I cannot color the part using the feature properties or face panels to get this effect.
Could someone point me to some code or to a function call inside of solidworks... Im using 2003
Thanks






RE: Assembly Macro Color (keeping component properties)
Properties =
Click the "Color" button and select the color you want for the part at the assembly stage.
Appearance =
Click "Color" in the flyout menu. In the Color Properties in the Property Manager you can select the Color of the part your seeking.
Regards,
Scott Baugh, CSWP
http://www.3dvisiontech.com
http://www.scottjbaugh.com
If you are in the SW Forum Check out the FAQ section
To make the Best of Eng-Tips Forums FAQ731-376
RE: Assembly Macro Color (keeping component properties)
CODE
http://www.EsoxRepublic.com
RE: Assembly Macro Color (keeping component properties)
Regards,
Scott Baugh, CSWP
http://www.3dvisiontech.com
http://www.scottjbaugh.com
If you are in the SW Forum Check out the FAQ section
To make the Best of Eng-Tips Forums FAQ731-376
RE: Assembly Macro Color (keeping component properties)
However using the MaterialPropertyValues goes into the part of the assembly and changes the color, then that color is then displayed throughout the assembly. The problem this creates is that all the subsequent parts that are in the assembly which share the same name are then colored the same.
I am interested in changing the color in the assembly for each individual part that is contained in the assembly. Not for every part that shares the same name inside the assembly.
List of the code:
Dim Temp As Variant
Dim (Everything else as an object) and
Dim Component() as Object
Set swApp = CreateObject("SldWorks.Application")
Set AssyDoc = swApp.ActiveDoc
Set Configuration = AssyDoc.GetActiveConfiguration()
Set RootComponent = Configuration.GetRootComponent()
Component = RootComponent.GetChildren
Set Child = Component(0)
Set Component2 = Child.GetModelDoc
Temp = Component2.MaterialPropertyValues
Temp(0) = 16711680
Temp(1) = 0
Temp(2) = 1
Temp(3) = 1
Temp(4) = 0.21
Temp(5) = 0.21
Temp(6) = 0.21
Temp(7) = 0.21
Temp(8) = 0.21
Component2.MaterialPropertyValues = Temp
I havent seen anything which can do this yet on the forums, but if someone can point me in the right direction that would be great
Thanks
RE: Assembly Macro Color (keeping component properties)
CODE
You are setting "Component2" to be the ModelDoc object, which is the part file. You want to change the properties of "Child".
http://www.EsoxRepublic.com
RE: Assembly Macro Color (keeping component properties)
Set Component2 = Child.GetModelDoc
but I changed the Child properties at the end
Child.MaterialPropertyValues = Temp
Something was wrong with mismatching the information
Thanks
RE: Assembly Macro Color (keeping component properties)
Have you looked at the macros on Matt Lombard's website?
Go to:
http://www.frontiernet.net/~mlombard/
then click the "Macro Library" button.
There is a macro in there to change color of all of the parts in an assembly. I don't know that it'll work *exactly* the way you want, but maybe it'll shed some light for a solution.
Ken