Visual Studio 2010和Autocad导入 [英] Visual Studio 2010 and Autocad Import
问题描述
我刚刚开始学习C#.是的,我是新手.
我想通过Microsoft Visual Studio 2010导入我在Autocad中创建的图形.
http://exchange.autodesk.com/autocadarchitecture/enu/online-help/浏览#WS73099cc142f48755f2fc9df120970276f7-5354.htm [ ^ ]
是我遵循此过程的Autodesk网站,这是我复制的以下代码.
-------------------------------------------------- -----------------------------
I just started studying C#. Yes I''m a newbie.
Through Microsoft Visual Studio 2010, I would like to import the drawing I created in Autocad.
http://exchange.autodesk.com/autocadarchitecture/enu/online-help/browse#WS73099cc142f48755f2fc9df120970276f7-5354.htm[^]
is the autodesk website where I followed the process, and here''s the following code I copied.
-------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Autodesk.AutoCAD.Runtime;
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.DatabaseServices;
[assembly: CommandClass(typeof(MyFirstProject1.Class1))]
namespace MyFirstProject1
{
public class Class1
{
[CommandMethod("AdskGreeting")]
public void AdskGreeting()
{
// Get the current document and database, and start a transaction
Document acDoc = Application.DocumentManager.MdiActiveDocument;
Database acCurDb = acDoc.Database;
// Starts a new transaction with the Transaction Manager
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 write
BlockTableRecord acBlkTblRec;
acBlkTblRec = acTrans.GetObject(acBlkTbl[BlockTableRecord.ModelSpace],
OpenMode.ForWrite) as BlockTableRecord;
/* Creates a new MText object and assigns it a location,
text value and text style */
MText objText = new MText();
// Specify the insertion point of the MText object
objText.Location = new Autodesk.AutoCAD.Geometry.Point3d(2, 2, 0);
// Set the text string for the MText object
objText.Contents = "Greetings, Welcome to the AutoCAD .NET Developer's Guide";
// Set the text style for the MText object
objText.TextStyleId = acCurDb.Textstyle;
// Appends the new MText object to model space
acBlkTblRec.AppendEntity(objText);
// Appends to new MText object to the active transaction
acTrans.AddNewlyCreatedDBObject(objText, true);
// Saves the changes to the database and closes the transaction
acTrans.Commit();
}
}
}
}
-------------------------------------------------- ------------------------------
我在CommandClass,CommandMethod,Document和Document Manager上遇到错误.
我引用了acdbmgd.dll,acmgd.dll(Autocad .NET API)文件,并添加了
使用Autodesk.AutoCAD.Runtime;
但是,错误提示找不到类型或名称空间.我不明白!
--------------------------------------------------------------------------------
I''m getting errors on CommandClass, CommandMethod, Document, and Document Manager.
I referecned acdbmgd.dll, acmgd.dll(Autocad .NET API ) files, and added
using Autodesk.AutoCAD.Runtime;
However, the error says that The type or namespace could not be found.I don''t get it!!
推荐答案
您要查找的关键字是ObjectARX.
http://www.objectarx.com/ [ ^ ]
这是Autodesk与AutoCAD的接口之一. SDK中还有很多示例.
祝你好运;-)
The keyword your''e lookin for is ObjectARX.
http://www.objectarx.com/[^]
That is (one of) Autodesk''s interface to AutoCAD. There sould be also a bunch of examples comming with the SDK.
good luck ;-)
这篇关于Visual Studio 2010和Autocad导入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!