Thank you the answer, but this is not what I'm looking for.
As I wroted I tried to set the lightweight components to resolved (with this function), but it takes lot of time.
Example with an assembly what contains about 2000 components, the whole traverse process takes more than five minutes if I resolved the lightweight componenets one by one. And sometimes I could not resolve the whole assembly (example huge assemblies) because of memory.
That is the reason why I would like to find other solution what I can use with lightweight mode.
Hi Norbert, if you check the suppression state of the selected component and it is lightweight, you can then use Document Manager to either read or write properties to the selected part file. If a part is loaded lightweight then it isn't made read only to the file system, therefore Document Manager can write to the file on disk. I remember testing this several years ago for the exact same reason as you mention, large assemblies or files can take a long time to resolve.
I have to concour with Declan McTiernan
Use the DocumentManager instead. This is basically the same as using GetModelDoc2 when the component is not suppressed/lightweight (unless the part open - which I'm assuming is not since it's suppressed/lightweight so that's good a sign). GetModelDoc2 would return the ModelDoc2 from the model file in its last saved state.
There is also another approach to do this (answer by @Jana_Fischer from another question):
My colleague gave me a solution that finishes what I started: The trick is to change some SolidWorks settings before opening the component model document file.
IDocumentSpecification copmDocSpec = _swApp.GetOpenDocSpec(comp.GetPathName());
compDocSpec.ReadOnly = true;
compDocSpec.Silent = true;
_swApp.DocumentVisible(false, compDocSpec.DocumentType); // allows opening the file without opening another window
_swApp.SetUserPreferenceToggle((int)swUserPreferenceToggle_e.swLockRecentDocumentsList, true); // prevents the opened file to appear in the recent document list
compDoc = _swApp.OpenDoc7(compDocSpec); // open file - user won't notice
_swApp.SetUserPreferenceToggle((int)swUserPreferenceToggle_e.swLockRecentDocumentsList, false); // change back
_swApp.DocumentVisible(true, compDocSpec.DocumentType); // change back
// Do what you want here
// get custom property for compDoc
Thank you Amen I tried also this method before, but I'd like to find what I can use without resolving a component
Thank you, it seems a bit complicated, but I gues there is the only way Thank you
you might try another option. This could be also reasonable because as you said you do not have so much memory.
- check state of component (resolve if it is lightweight)
- read property
- save property (external file or memory)
- set component back to lightweight
I did not try it, btw.
When your application is standalone app. or vba macro, the issue of operation speed might be there. Add-in is faster.
Nevertheless how much time does it take?
Thank you Patric I tried this method before, but I'd like to find what I can use without resolving a component.