您的位置:首页 > 移动开发 > Objective-C

【每天一个demo】编写Hello World语句:访问ObjectARX.NET封装类

2009-02-24 20:57 260 查看
启动vs2005,新建项目,选择AutoCAD Managed c#Project模板(前提是已经安装好ObjectARX),打开Commands.cs代码。

进行编写,代码如下:

// (C) Copyright 2002-2007 by Autodesk, Inc.
//
// Permission to use, copy, modify, and distribute this software in
// object code form for any purpose and without fee is hereby granted,
// provided that the above copyright notice appears in all copies and
// that both that copyright notice and the limited warranty and
// restricted rights notice below appear in all supporting
// documentation.
//
// AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS.
// AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF
// MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE.  AUTODESK, INC.
// DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE
// UNINTERRUPTED OR ERROR FREE.
//
// Use, duplication, or disclosure by the U.S. Government is subject to
// restrictions set forth in FAR 52.227-19 (Commercial Computer
// Software - Restricted Rights) and DFAR 252.227-7013(c)(1)(ii)
// (Rights in Technical Data and Computer Software), as applicable.
//

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

[assembly: CommandClass(typeof(CsMgdAcad1.Commands))]

namespace CsMgdAcad1
{
/// <summary>
/// Summary description for Commands.
/// </summary>
public class Commands
{
public Commands()
{
//
// TODO: Add constructor logic here
//
}

// Define Command "AsdkCmd1"
[CommandMethod("helloword")]
static public void helloword() // This method can have any name
{
Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
ed.WriteMessage("Hello World,本人第一个程序");
// Put your command code here
}

}
}


生成下解决方案,然后编译下。这时会弹出autocad2007,在cad里输入命令:netload,找到CsMgdAcad1.dll该组件,然后再输入命令:helloworld,这时会显示出一个语句:Hello World,本人第一个程序,简单是简单了点。呵呵,慢慢来
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐