when i run this code it opens the assembly which i prefer but its opening with all components invisible
how can i change the visibility property of opening assembly
SldWorks swApp = new SldWorks();
ModelDoc2 swModel = default(ModelDoc2);
DocumentSpecification swDocSpecification = default(DocumentSpecification);
string[] componentsArray = new string[1];
object[] components = null;
string name = null;
int errors = 0;
int warnings = 0;//set specification
swDocSpecification =(DocumentSpecification)swApp.GetOpenDocSpec("C:\\Users\\Public\\Documents\\SOLIDWORKS\\SOLIDWORKS2018\\samples\\tutorial\\advdrawings\\bowl and chute.sldasm");
componentsArray[0] = "food bowl-1@bowl and chute";
components = (object[])componentsArray;
swDocSpecification.ComponentList = components;
swDocSpecification.Selective = true;
name = swDocSpecification.FileName;
swDocSpecification.DocumentType = (int)swDocumentTypes_e.swDocASSEMBLY;
swDocSpecification.DisplayState = "new display state-1";
swDocSpecification.ReadOnly = false;
swDocSpecification.UseLightWeightDefault = false;
swDocSpecification.LightWeight = true;
swDocSpecification.Silent = true;
swDocSpecification.IgnoreHiddenComponents = true;
//open the assembly
swModel = (ModelDoc2)swApp.OpenDoc7(swDocSpecification);
errors = swDocSpecification.Error;
warnings = swDocSpecification.Warning;
also tried this code and solidworks collapsed
2019 SOLIDWORKS API Help - Open Assembly Document Example (C#)
ModelDoc2 swModel = default(ModelDoc2);
DocumentSpecification swDocSpecification = default(DocumentSpecification);
string[] componentsArray = new string[1];
object[] components = null;
string name = null;
int errors = 0;
int warnings = 0;
//Set the specifications swDocSpecification = (DocumentSpecification)swApp.GetOpenDocSpec("C:\\Users\\Public\\Documents\\SOLIDWORKS\\SOLIDWORKS 2018\\samples\\tutorial\\advdrawings\\bowl and chute.sldasm");
componentsArray[0] = "food bowl-1@bowl and chute";
components = (object[])componentsArray;
swDocSpecification.ComponentList = components;
swDocSpecification.Selective = true;
name = swDocSpecification.FileName;
swDocSpecification.DocumentType = (int)swDocumentTypes_e.swDocASSEMBLY;
swDocSpecification.DisplayState = "Default_Display State-1";
swDocSpecification.UseLightWeightDefault = false;
swDocSpecification.LightWeight = true;
swDocSpecification.Silent = true;
swDocSpecification.IgnoreHiddenComponents = true;
//Open the assembly document as per the specifications
swModel = (ModelDoc2)swApp.OpenDoc7(swDocSpecification);
errors = swDocSpecification.Error;
warnings = swDocSpecification.Warning;
this code works