×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Assembly Macro Color (keeping component properties)

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

RE: Assembly Macro Color (keeping component properties)

RMB the part in the assembly and either "Click Properties" or "Appearance"

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)

below are excerpts pasted from SW help...

CODE

Component2.MaterialPropertyValues = MaterialPropertyValues (VB Set property)

Quote (SWAPIhelp):

The format of the parameters or return values is an array of doubles as follows:
[ R, G, B, Ambient, Diffuse, Specular, Shininess, Transparency, Emission ]

Due to illness, the part of The Tick will be played by... The Tick.
http://www.EsoxRepublic.com

RE: Assembly Macro Color (keeping component properties)

(OP)
Hi all thanks for the quick response...
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)

Here's your culprit:

CODE

Set Component2 = Child.GetModelDoc

You are setting "Component2" to be the ModelDoc object, which is the part file.  You want to change the properties of "Child".

Due to illness, the part of The Tick will be played by... The Tick.
http://www.EsoxRepublic.com

RE: Assembly Macro Color (keeping component properties)

(OP)
Thanks for the info I actually had to keep
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)

tgoudie000,
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

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources