Referencing AcSmComponents.dll error

Referencing AcSmComponents.dll error

Poncho_Slim
Enthusiast Enthusiast
2,104 Views
13 Replies
Message 1 of 14

Referencing AcSmComponents.dll error

Poncho_Slim
Enthusiast
Enthusiast

Hello!
I am building a .NET solution for AutoCAD in C#.
I want to access the Sheet Set Manager through the API, however I am unable to reference the AcSMComponents.dll file to begin creating a SheetSet object.

I am using AutoCAD 2019.
I am writing my code in Visual Studio.

When I go to the Solution Explorer, and I use the reference manager to add the AcSMComponents.dll file, it gives me an error message:  A reference to 'C:\Program Files\Autodesk\AutoCAD2019\AcSmComponents.dll' could not be added. Please make sure that the file is accessible, and that it is a valid assembly or COM component.

How can I go about adding this reference.

My ultimate goal would be to access the sheets within the SheetSetManager from a document and access the data from those sheets. Data such as the Number, File Name, and LayoutName would ultimately be exported to a database. I would also like to access blocks within the sheets to modify certain aspect of them.

However, none of this can be started without the reference working correctly.
Any advice would be appreciated.

0 Likes
2,105 Views
13 Replies
Replies (13)
Message 2 of 14

jeffHGCE
Advocate
Advocate

Have you tried adding from COM tab?

2019 would be AcSmComponents20 I think.

jeffHGCE_0-1679708143630.png

 

0 Likes
Message 3 of 14

Poncho_Slim
Enthusiast
Enthusiast

I was able to successfully reference that file. The version that was accessible for me was ACSMCOMPONENTS23Lib. However, that file got me nowhere. I was trying to follow along with it, but it was unable to access the document on its own. The syntax was also very different than the syntax that came with the three files I originally referenced.
I have been using accoremgd, acdbmgd, and acmgd. I was expecting to be able to use the SheetSet object with the AcSMComponent.dll. The syntax for the ACSMCOMPONENTS23Lib was very different and did not synergize with the three references I have listed above. I was able to create an AcSmSheetSet object but I am unsure on how I would instantiate the document, access the database/SheetSet file, and move forward.

I guess what I am saying is that I would like to find a way to reference the AcSmComponents.dll file in hopes that it will synergize with the other three files I referenced. Since I already have a lot of code built around those references, I would like to continue using that. 

0 Likes
Message 4 of 14

Ed__Jobe
Mentor
Mentor

You should read this blog post before going any farther.

 

On a side note, you can go to this page to edit your forum name so that it doesn't have the extraneous letters that got added when you signed up.

Ed


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
How to post your code.

EESignature

0 Likes
Message 5 of 14

Poncho_Slim
Enthusiast
Enthusiast

Thank you for your recommendation.

I have quickly run into another issue. Following down the rabbit hole of the ACSMCOMPONENTS23Lib, I would need the file that points to the SheetSet. I have trouble understanding how I would automate this. Is the SheetSet not tied to a document? Would the SheetSet not be accessible through a document? or is it a completely separate entity. I was imagining that the SheetSet could be accessed through a document or a document's database. If it is its own file, and I could not access it through a document, I would obviously need a file name, but then I have trouble imagining how I could automate a process of handling and parsing all sheets in a SheetSet via a document open on an AutoCAD instance.

 

Also thank you for helping me change my name haha

0 Likes
Message 6 of 14

Ed__Jobe
Mentor
Mentor

No, the sheetset is a dst file. Maybe you should play around with the SHEETSET command to get familiar with it.

Ed


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
How to post your code.

EESignature

0 Likes
Message 7 of 14

chandrakantakorat002
Explorer
Explorer

Could anyone please update on the original issue of "unable to reference the AcSMComponents.dll file to begin creating a SheetSet object", I am trying to use the APIs with Python and not able to reference the interface.

 

So far, i have generated modules using tlb file which is from AcSm*.tlb file, I am able to reference ACSMCOMPONENTS24Lib.py file but while accessing the AcSmSheetSetMgr using interface object it gives error "Problem in loading application"

I have correct entry in registry as well. I am able to use AcCmColor but not AcSmSheetSetMgr. I have tried to register the DLL but it fails with error that "entry point DllServerRegisterServer was not found"

 

Here's the python code i am trying.

import win32com.client

import os
import glob

import comtypes.client
# generate modules
for pattern in ("acax*enu.tlb", "axdb*enu.tlb","AcSm*.tlb"):
pattern = os.path.join(
r"C:\Program Files\Common Files\Autodesk Shared",
pattern
)
tlib = glob.glob(pattern)[0]
comtypes.client.GetModule(tlib)


def get_sheet_set_manager():
acad = win32com.client.Dispatch("AutoCAD.Application.24")

sm_components = acad.GetInterfaceObject("AcSmComponents.AcSmSheetSetMgr.24")
# sm_components = acad.GetInterfaceObject("AutoCAD.AcCmColor.24") # This is working
if sm_components:
print("Sheet Set Manager object retrieved successfully.")
return sm_components
else:
print("Failed to retrieve Sheet Set Manager object.")
return None

# Example usage
sheet_set_manager = get_sheet_set_manager()

Attaching error screenshot for dll registration.  Any input/suggestion on this will be truly helpful. 

Message 8 of 14

daniel_cadext
Advisor
Advisor

I was just trying the same thing earlier today

watching with interest

Python for AutoCAD, Python wrappers for ARX https://github.com/CEXT-Dan/PyRx
0 Likes
Message 9 of 14

norman.yuan
Mentor
Mentor

I think one DOES NOT call AcadApplication.GetInterfaceObject() to get AcSmSheetManager. The method GetInterfaceObject() is commonly used for AutoCAD verticals to get vertical-specific COM objects that HAVE BEEN INSTANTIATED when the verticals run. That is, they are live instances of COM objects, the custom code we write do not create them, we only need to reach them via GetInterfaceObject().

 

However, in the case of Sheet Manager, it does not automatically exist in a running AutoCAD session, you need to "new" it (create an instance with your own code). Not sure python syntax, but if it is C#:

 

var sheetManager=new AsCmSheetManager();

...

 

Norman Yuan

Drive CAD With Code

EESignature

0 Likes
Message 10 of 14

Ed__Jobe
Mentor
Mentor

@norman.yuan is correct. Further, a sheetset object is created when you read the contents of a dst file into memory. Fenton Webb gives you some sample VB.Net code in the blog post I linked to  in post 4. Look at the first code sample on how to open a dst file.

Ed


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
How to post your code.

EESignature

0 Likes
Message 11 of 14

ActivistInvestor
Mentor
Mentor

Try adding a reference to AcSmComponents.Interop.dll to your project.

0 Likes
Message 12 of 14

daniel_cadext
Advisor
Advisor

Since its python

win32com.client makepy with acsmcomponents24.tlb (ARX SDK)  will give you a hint.

Normally it will generate all if the interface classes, but it doesn’t with AcSmSheetManager

 

I was able to create an instance or AcSmSheetManager by creating an interface with the IIDs makepy generated

But it would be a long slog to do this if you wanted to generate wrappers

 

I want to generate wrappers for my project, but I may switch to C++,  C++ and COM are also fun, so a big ‘YAY’

Python for AutoCAD, Python wrappers for ARX https://github.com/CEXT-Dan/PyRx
Message 13 of 14

chandrakantakorat002
Explorer
Explorer

Thanks Daniel for your inputs. 

Could you please give some code example on how you have created an instance or AcSmSheetManager by creating an interface with the IIDs makepy generated using python/powershell? 

And as a part of note, I am trying this with trial version. I hope that is not the issue here.

0 Likes
Message 14 of 14

chandrakantakorat002
Explorer
Explorer

@norman.yuan By any chance, do you know  how can we achieve the same using powershell?

0 Likes