Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations cowski on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Change transparency of selected part that is loaded as lightweight

Status
Not open for further replies.

neshom

Mechanical
Joined
Feb 7, 2016
Messages
43
Location
AU
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:
	                 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?
 
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)
 
Thanks for your reply.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top