几何尺寸与公差论坛------致力于产品几何量公差标准GD&T (GDT:ASME)|New GPS(ISO)研究/CAD设计/CAM加工/CMM测量  


返回   几何尺寸与公差论坛------致力于产品几何量公差标准GD&T (GDT:ASME)|New GPS(ISO)研究/CAD设计/CAM加工/CMM测量 » 仿射空间:CAX软件开发(三)二次开发与程序设计 » CAD二次开发 » AutoCAD二次开发 » ObjectARX(C++)
用户名
密码
注册 帮助 会员 日历 银行 搜索 今日新帖 标记论坛为已读


 
 
主题工具 搜索本主题 显示模式
旧 2009-04-16, 10:37 AM   #1
yang686526
高级会员
 
注册日期: 06-11
帖子: 14579
精华: 1
现金: 224494 标准币
资产: 234494 标准币
yang686526 向着好的方向发展
默认 【转帖】objectarx&dummies教程(九)—— interacting with autocad

objectarx&dummies教程(九)—— interacting with autocad
objectarx&dummies教程(九)—— interacting with autocad
class 9 - interacting with autocad
hello,
on the last class i have presented how to perform selection sets. this class i will show how can you interact with autocad using global functions and acquiring information such as numbers, coordinates, system variables and much more.
invoking commands
objectarx provide us two global functions that allows us to invoke registered commands. this functionality is very handy and will help users to perform quick operations that don't require complex procedures. even this method is quite simple you should avoid using it in complex and huge operations. this method may also create problems when dealing with events handling.
the two provided functions are acedcmd() and acedcommand(). the first one invokes the command through a passed in resbuf list which will inform all command parameters. the second function will receive a variable number of parameters which will reproduce the way you fire the command from the prompt interface. below are these functions signature:
int acedcmd(const struct resbuf * rbp);
int acedcommand(int rtype, ... unnamed);
to build the resbuf list when using acedcmd() there is a utility function called acutbuildlist() which constructs this linked list easily. you just need to pass paired values with codes that describe the types and end the list with a 0 or rtnone value. another good practice is to clear the command prompt, calling acedcommand(rtnone) , after issued the command. don't forget to free memory used, when using resbuf pointers, through the acutrelrb() utility function to avoid memory leaks. there are several ways to use theses functions and i will show some of them below:
acedcmd():
a) moving the last created entity based on (0,0,0):
ads_point pt;
pt[0] = pt[1] = pt[2] = 0.0;
struct resbuf *mv;
mv = acutbuildlist(rtstr,"_move",rtstr,"_last",rtstr,"",
rtpoint,pt,rtstr,pause,0);
acedcmd(mv);
acedcommand(rtnone);
acutrelrb(mv);
b) calling a "redraw" native command:
struct resbuf *cmdlist;
cmdlist = acutbuildlist(rtstr, "_redraw", 0);
acedcmd(cmdlist);
acedcommand(rtnone);
acutrelrb(cmdlist);
acedcommand():
a) calling a zoom command and pausing for user input:
acedcommand(rtstr, "zoom", rtstr, pause, rtnone);
b) creating both a circle and a line entities:
acedcommand(rtstr, "circle", rtstr, "10,10",rtstr, pause,
rtstr, "line", rtstr, "10,10", rtstr, "20,20", rtstr, "", 0);
system variables
your application will probably need to access autocad system variables that can be read or write. objectarx provide two functions to deal with these variables using the resbuf structure to access and/or modify values. the function are called acedgetvar() and acedsetvar() and below are their signatures:
int acedgetvar(const char * sym,struct resbuf * result);
int acedsetvar(const char * sym,const struct resbuf * val);
the first parameter is the variable name the second the resbuf pointer to set / get information. the following example show how to change the fillet radius which is stored through a system variable:
struct resbuf rb, rb1;
acedgetvar("filletrad", &rb);
rb1.restype = rtreal;
rb1.resval.rreal = 1.0;
acedsetvar("filletrad", &rb1);
it is very important that you specify the correct type of resbuf item acquired.
in this case, the fillet radius is a real number which is rtreal type.
user input functions
there are additional global functions to allow interaction with users via command prompt interface. each of these functions could be used alone or with other ones. the following table shows what each function does:
acedgetint
gets an integer value
acedgetreal
gets a real value
acedgetdist
gets a distance
acedgetangle
gets an angle (oriented to 0 degrees specified by the angbase)
acedgetorient
gets an angle (oriented to 0 degrees at the right)
acedgetpoint
gets a point
acedgetcorner
gets the corner of a rectangle
acedgetkword
gets a keyword
acedgetstring
gets a string
each of these functions returns a int number as a result code that could be one of the following:
rtnorm
user entered a valid value
rterror
the function call failed
rtcan
user entered esc
rtnone
user entered only enter
rtrej
autocad rejected the request as invalid
rtkword
user entered a keyword or arbitrary text
autocad allows you to prevent invalid values when user respond to your input functions. this feature can be made through the acedinitget() function which can receive one or a combination of the following values:
rsg_nonull
disallow null input
rsg_nozero
disallow zero values
rsg_noneg
disallow negative values
rsg_nolim
do not check drawing limits, even if limcheck is on
rsg_dash
use dashed lines when drawing rubber-band line or box
rsg_2d
ignore
z
coordinate of 3d points (acedgetdist() only)
rsg_other
allow arbitrary input—whatever the user enters
the following example shows how to acquire a value greater than zero:
int age = -1;
acedinitget(rsg_nonull rsg_nozero rsg_noneg, null);
acedgetint("how old are you? ", &age);
yang686526离线中   回复时引用此帖
GDT自动化论坛(仅游客可见)
 


主题工具 搜索本主题
搜索本主题:

高级搜索
显示模式

发帖规则
不可以发表新主题
不可以回复主题
不可以上传附件
不可以编辑您的帖子

vB 代码开启
[IMG]代码开启
HTML代码关闭

相似的主题
主题 主题发起者 论坛 回复 最后发表
【转帖】autocad arx 学习笔记(三)(转载) yang686526 ObjectARX(C++) 0 2009-04-16 09:12 AM
【转帖】autocad arx 学习笔记(一)(转载) yang686526 ObjectARX(C++) 0 2009-04-16 09:12 AM
【转帖】moving from autocad lisp to sw macros yang686526 SolidWorks二次开发 0 2009-04-13 12:57 PM
如何在VB中连接AutoCAD cad DirectDWG 1 2007-01-28 04:05 PM
ObjectARX类库介绍 huangyhg ObjectARX(C++) 0 2007-01-02 06:51 PM


所有的时间均为北京时间。 现在的时间是 08:47 AM.


于2004年创办,几何尺寸与公差论坛"致力于产品几何量公差标准GD&T | GPS研究/CAD设计/CAM加工/CMM测量"。免责声明:论坛严禁发布色情反动言论及有关违反国家法律法规内容!情节严重者提供其IP,并配合相关部门进行严厉查处,若內容有涉及侵权,请立即联系我们QQ:44671734。注:此论坛须管理员验证方可发帖。
沪ICP备06057009号-2
更多