×
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

Change transparency of selected part that is loaded as lightweight

Change transparency of selected part that is loaded as lightweight

Change transparency of selected part that is loaded as lightweight

(OP)
Using Solidworks API (C#), I'd like to change the transparency of a lightweight part that is selected in an assembly. Here is the code that I am using up to where I get an error (last line):

CODE --> C#

ModelDoc2 swModel = (ModelDoc2)swApp.ActiveDoc;

            SelectionMgr swSelectionMgr = (SelectionMgr)swModel.SelectionManager;
            int intSelectedObjectCount = swSelectionMgr.GetSelectedObjectCount2(-1);

            Component2 swComponent = (Component2)swSelectionMgr.GetSelectedObjectsComponent4(1, -1);

            ModelDoc2 swModelDoc2 = (ModelDoc2)swComponent.GetModelDoc(); 

If the part is not lightweight, all is good! But when the part is lightweight, the variable swModelDoc2 is null and the code does not continue after the last line above!

Do you know how I can solve this?

RE: Change transparency of selected part that is loaded as lightweight

Are you trying to change transparency at the part level (all instances of the part change, and the part is transparent when you open in a window) or component level (just this one instance in the assembly changes)? If you want to change at the part level, I believe you'll have to set that component to resolved before you can get its ModelDoc2.

-handleman, CSWP (The new, easy test)

RE: Change transparency of selected part that is loaded as lightweight

(OP)
Thanks for your reply.

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