.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Acsmcomponents.tlb referencing from local folder

5 REPLIES 5
Reply
Message 1 of 6
Ajilal.Vijayan
1309 Views, 5 Replies

Acsmcomponents.tlb referencing from local folder

Hai all.

 

I am trying to reference the sheet set from C:\ObjectARX 2012\inc-win32\acsmcomponents18.tlb folder.

 

But after selecting the file from above location, the reference path is showing from the project  \bin  folder.

I have set the 'Copy local' to No also.

 

I am using Civil 3D 2012,Visual Studio 2010 and a 32bit operation system.

 

Also how we can avoid the GAC folder to reference the path ?

Sometimes when I am adding the reference to sheet set components, Autocad/ObjectDBX components loading from the GAC folder. [ See the attached Image]

 

Thanks

AJIL

5 REPLIES 5
Message 2 of 6

Sheet set component defined in AcSmComponents18.tlb is a COM componenet, not a .NET stuff. Autodesk provides PIA (primary interop assembly) to the Acad/ObjectDBX COM components and has them installed in the GAC when Autocad is installed. Hwever, Autodesk does not supply a .NET interop wrapper.

 

So, when you manually add the reference to to it, VS will generate a .NET interop wrapper. In VS2010, VS may set the interop DLL as "Embedded". You should change it to False, and you SHOULD set "Copy Local" to True (because AutoCAd does not supply this .NET interop wrapper).

 

To use COM component in .NET application I would not use any DLL/TLB from ObjectAXR SDK. Since COM components must be installed and registered, only the registered ones work with the running computer. If you use the same DLL/TLB from other source (such as ObjectARX SDK), there is always CHANCE the DLL\TLB may be different from the ones registered with your computer. To run a program that uses COM components, only registered components matter.

Norman Yuan

Drive CAD With Code

EESignature

Message 3 of 6

Hai

thanks for the reply.


So Instead of using the DLL/TLB files from OBJARX SDK folder, you mean it should be referenced from Autodesk shared folder from Common files folder ?

 

Also now I am getting some warnings and while using the compiled dll in autocad, when I am entering the app command I am getting error saying COM+ is required.

 

Warings

 

Warnings.jpg

 

Error

 

Error.jpg

 

 


Message 4 of 6

What kind of application are you doing and where does it run? You are not doing something that runs on the server side, are you?

Norman Yuan

Drive CAD With Code

EESignature

Message 5 of 6

 

No, I am not doing which run on server.

 

I would like to create an application which can be run in AutoCAD 2012.

 

The application will ask the user to select a *.dst file and after selecting the file , the sheet set properties will display in a dialog box where you can edit the custom properties and will have an option to write/read from an external source [ Excel or Access].

 

I am new to .NET and I have created a similar program in VBA , but as AutoCAD no longer supporting VBA and VLISP doesnt allow to access the sheet set , I am trying to create in .NET.

 

Regards

AJIL

 

 

 

Message 6 of 6

I put together some simple code that works with Autocad 2012 (64bit). I tried with both VS2008 (targeting .NET 3.5, which I commented out "<supported runtime...4.0/>" in acad.exe.config) and VS2010 (target .NET 4.0). Both works.

 

In both projects, I added reference to AcSmComponents18 1.0 type library from COM tab of References dialog box (i.e. I set reference to the registered DLL/TLB installed by AutoCAd, not by browsing to the one from ObjectARX SDK). Once the reference is set, VS generate a ,NET wrapper to the COM component: Interop.ACSMCOMPONENTS18Lib.dll

 

The code as following:

 

A Sheetset utility class:

 

using ACSMCOMPONENTS18Lib;

namespace Acad2012SheetSet
{
    public class SheetSetUtil
    {
        private static SheetSetUtil _instance = null;
        private static AcSmSheetSetMgr _mgr=null;

        public SheetSetUtil()
        {
            _mgr = new AcSmSheetSetMgr();
        }

        ~SheetSetUtil()
        {
            if (_mgr != null)  _mgr.CloseAll();
        }

        public static SheetSetUtil Instance
        {
            get
            {
                if (_instance == null) _instance = new SheetSetUtil();
                return _instance;
            }
        }

        public SheetSetInfo GetSheetSetInformation(string dstFileName)
        {
            SheetSetInfo info = null;

            AcSmDatabase db = _mgr.OpenDatabase(dstFileName, false);
            AcSmSheetSet ss = db.GetSheetSet();

            info = new SheetSetInfo();
            info.SheetSetName = ss.GetName();

            return info;
        }
    }
}

 A data class:

namespace Acad2012SheetSet
{
    public class SheetSetInfo
    {
        public string SheetSetName { set; get; }
    }
}

 and finally a command class:

 

using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.EditorInput;
using Autodesk.AutoCAD.Runtime;

[assembly: CommandClass(typeof(Acad2012SheetSet.MyCommands))]

namespace Acad2012SheetSet
{
    public class MyCommands 
    {
        [CommandMethod("SSInfo", CommandFlags.Session)]
        public static void GetSheetSetName()
        {
            Document dwg = Application.DocumentManager.MdiActiveDocument;
            Editor ed = dwg.Editor;

            string ssFile = 
                @"C:\Users\norm\Documents\AutoCAD Sheet Sets\TestSet.dst";

            try
            {
                SheetSetInfo ssInfo = 
                    SheetSetUtil.Instance.GetSheetSetInformation(ssFile);
                ed.WriteMessage("\nSheetSet Name: {0}", ssInfo.SheetSetName);
            }
            catch(System.Exception ex)
            {
                ed.WriteMessage("\nError: {0}", ex.Message);
            }
        }
    }
}

 Compile and NETLOAD the code into AutoCAD, and run the command "SSInfo", the sheetset's name prints at command line correctly.

 

However, there is one thing I have to point out:

 

InVS2008 project (it would be the same as VS2010 project targeting .NET3.x), the Copy Local of the generated interop assembly should be set to True.

 

While in VS2010 targeting .NET4.0, if I set "Embedded" of the interop assembly to False and set CopyLocal to "True", I get runtime exception when the code instantiate AcSmSheetSetMgr class. I had to embed the interop assembly. This is different from what I said in previous post. However, there are reports saying embedding interop assembly in Acad add-in would not work (see this link http://www.theswamp.org/index.php?topic=41497.0).

 

So, I guess, we have to try both embed and not embed in somce cases.

 

Nonetheless, the code shown above works form me.

 

Norman Yuan

Drive CAD With Code

EESignature

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost