Hi,
I can get components of assembly file after open it in solidworks as below
swApp.OpenDoc6(@"C:\\........\\........\\.....", (int)swDocumentTypes_e.swDocASSEMBLY, (int)swOpenDocOptions_e.swOpenDocOptions_Silent, "", ref errors, ref warnings);
swDoc = (ModelDoc2)swApp.ActiveDoc;
swAssembly = (AssemblyDoc)swDoc;
object[] Components = null;
Components = (object[])swAssembly.GetComponents(false);
foreach (Object SingleComponent in Components)
{
swComp = (Component2)SingleComponent;
string wholePath=swComp.GetPathName());
}
However I want to know about are there any way to get whole these components without opening solidworks by using document manager api and it's key?
If not i will continue old way...
Best regards.
SolidworksApi macros
Hi,
Document manager don't allow because it don't open document graphically.
Check that link for (limited) possibilities : 2015 SOLIDWORKS API Help - SOLIDWORKS Document Manager API Help
Philippe Dutremble
Reading 's question I think this is exactly what SOLIDWORKS Document Manager is designed to do - retrieve external files references without opening the file in SOLIDWORKS.
For example:
http://help.solidworks.com/2016/english/api/swdocmgrapi/get_current_name_of_configuration_of_suppressed_component_example_csharp.htm
Perhaps I've misunderstood.
Regards,
Dan
Yes.... I can open solidworks and use its api. however it takes lots of time... If it is possible I want to use document manager api to reach same aim. I did not find anything in the document manager therefore I asked it to forum. May be some one knows?
Best regards.
Document Manager API allows to do following tasks:
Allows you to write applications that emulate file management tools to perform such tasks as renaming, replacing, and copying SOLIDWORKS documents.
It is an independent software component that provides read-write functionality for SOLIDWORKS documents. It includes interfaces for the document and configurations. These interfaces have read-only and read-write properties and methods.
Here are some lines from example in API help file, you can see the Daniel's link for complete example:
Dim dmClassFact As SwDMClassFactory
Dim dmDocMgr As SwDMApplication4
Dim dmDoc As SwDMDocument18
dmClassFact = CreateObject("SwDocumentMgr.SwDMClassFactory.1")
dmDocMgr = dmClassFact.GetApplication(sLicenseKey)
dmDoc = dmDocMgr.GetDocument(sDocFileName, GetDocType(sDocFileName), True, nRetVal)
Thanks both of you @Digvijay Taunk and @Daniel Seaman
I get it and solved. Next step ,,, getting bounding box information from document manager???
"getting bounding box information from document manager" - You're out of luck there I'm afraid.
SOLIDWORKS Document Manager is designed to provide lightweight access to SOLIDWORKS data. To keep it lightweight, SWDM does not have access to all of the data contained in the file, only a small subset. Modifying SWDM to allow access to bounding box data would result in a significant performance regression for most existing client applications.
Regards,
Dan
Hi Cetin,
can you share the code? I'm working on vb.net to get the assembly component list (a simple path list of the components....same as PackAndGo but without opening SW)but without success. My starting point is this 2015 SOLIDWORKS API Help - Replace Component (VB.NET) , I have the license string and I only change this part
Dim bResult As Boolean = swDmComponent.Replace("C:\Program Files\SOLIDWORKS Corp\SOLIDWORKS\samples\tutorial\smartcomponents\lockwasher.sldprt", "Default", False)
to avoid any replace....I need to fill only an array!
The error comes from here
vComponents = DirectCast(activeConfig.GetComponents(), Object())
when the code call lenght
For i = 0 To vComponents.Length - 1
the object is always NULL.
SW version:2016
Visual studio express 2015
Thanks!!
I found the problem: using windows7 and vs 2013 it works.
Now next question: how getting components list included nested assembly?
Hello ,
Could you please share the code to read assembly component properties?
Thanks