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.


Categories: API∕Macros

Comments
Last comment By: Sachin Mahajan   Wed, 22 Nov 2017 10:46:13 GMT
Re: document Manager getting assembly components.

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

By: Philippe Dutremble  Tue, 17 Nov 2015 14:40:12 GMT
Re: document Manager getting assembly components.

Reading Cetin'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

By: Daniel Seaman  Tue, 17 Nov 2015 15:10:05 GMT
Re: document Manager getting assembly components.

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.

By: Cetin Ozgur Baltaci  Tue, 17 Nov 2015 19:27:18 GMT
Re: document Manager getting assembly components.

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)

By: Digvijay Taunk  Wed, 18 Nov 2015 07:28:00 GMT
Re: document Manager getting assembly components.

Thanks both of you @Digvijay Taunk and @Daniel Seaman 

 

I get it and solved. Next step   ,,, getting bounding box information from document manager???

By: Cetin Ozgur Baltaci  Wed, 18 Nov 2015 16:25:54 GMT
Re: document Manager getting assembly components.

"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

By: Daniel Seaman  Wed, 25 Nov 2015 14:08:09 GMT
Re: document Manager getting assembly components.

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?

By: Gian Luca Taroni  Wed, 06 Apr 2016 20:10:57 GMT
Re: document Manager getting assembly components.

Hello Cetin Ozgur Baltaci,

Could you please share the code to read assembly component properties?

 

Thanks

By: Sachin Mahajan  Wed, 22 Nov 2017 10:46:13 GMT
You are not authorized to view this page No results found! Suggestions: Check spelling, try a different search, or browse topics below.