用于 c# 的 ObjectARX SDK [英] ObjectARX SDK for c#

查看:38
本文介绍了用于 c# 的 ObjectARX SDK的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

最近两天,我一直在寻找带有步骤的示例代码,这些步骤可能有助于我理解 Autocad API.所以我可以在 C# 中使用代码.

For last two days I have looking for sample code with steps which may help me to understand the Autocad API. so I can use the code in C#.

[CommandMethod("LISTGEn")]
public static void ListEntities()
        {
            Document acDoc = Autodesk.AutoCAD.ApplicationServices.Core.Application.DocumentManager.MdiActiveDocument;
            Database acCurDb = acDoc.Database;

            using (Transaction acTrans = acCurDb.TransactionManager.StartTransaction())
            {
                // Open the Block table record for read
                BlockTable acBlkTbl;
                acBlkTbl = acTrans.GetObject(acCurDb.BlockTableId,OpenMode.ForRead) as BlockTable;

                // Open the Block table record Model space for read
                BlockTableRecord acBlkTblRec;
                acBlkTblRec = acTrans.GetObject(acBlkTbl[BlockTableRecord.ModelSpace],OpenMode.ForRead) as BlockTableRecord;

                int nCnt = 0;
                acDoc.Editor.WriteMessage("
Model space objects: ");

                // Step through each object in Model space and
                // display the type of object found
                foreach (ObjectId acObjId in acBlkTblRec)
                {
                    acDoc.Editor.WriteMessage("
" + acObjId.ObjectClass.DxfName);

                    nCnt = nCnt + 1;
                }
                acDoc.Editor.WriteMessage(nCnt.ToString());
                // If no objects are found then display a message
                if (nCnt == 0)
                {
                    acDoc.Editor.WriteMessage("
 No objects found");
                }

                // Dispose of the transaction
            }

        } 

我可以运行上面的代码,但它运行不正常.我很难理解如何让它与 Autocad 一起工作.我引用了 OjectARX SDK,我正在使用 VS2010 和 Autocad 2012.感谢您的帮助.

I can run the above code, but it's not functioning properly. It's difficult for me to understand how to get it work with Autocad. I have OjectARX SDK referenced, I am working with VS2010 and Autocad 2012. Thank You for your help.

推荐答案

好的,我只知道需要的东西

Ok, I got it only thing that is being required

1.) 是创建类库

2.) 然后需要在类中输入上面的代码.

2.) Then need to enter the above code in the class.

3.) 按 F5 构建您的项目.

3.) Build your project by pressing F5.

4.) 将在项目的 bin/debug/文件夹中创建一个 DLL

4.) A DLL will be created in the bin/debug/ folder of your project

5.) 打开 Autocad.

5.) Open Autocad.

6.) 编写 netload 命令.

6.) Write netload command.

7.) 选择创建的 DLL,然后编写命令LISTGEN",然后 kaboom 它将显示您项目中的所有对象.

7.) Select the DLL created and then write command "LISTGEN" and than kaboom it will show all the objects in your project.

这篇关于用于 c# 的 ObjectARX SDK的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆