首页 > 编程知识 正文

cad二次开发是什么意思,cad二次开发论坛

时间:2023-05-03 06:22:59 阅读:156558 作者:858

文章序言1、是否要实时绘制EntityJig和DrawJig? 二、操作步骤1 .添加引用2 .自定义RectJig类,DrawJig3.函数调用3 .结果演示总结

首先,在CAD的二次开发项目中,用户需要选择一个矩形范围并在该范围内进行计算。 最初,把每一个点捡起来连接起来,画成四边形。 考虑到用户体验,应该进行完善,让用户直接画出矩形框。 因此,需要获得四个拐角坐标,就像在CAD界面中使用的矩形一样。

写到这里,突然觉得CAD上有矩形画。 编写插件为什么要写现有的功能呢? 深思。 客户会不会嫌画了长方形再选角? )

到现在,我花了很多时间查资料,所以和这个做记录吧~

要使您可以随着鼠标移动显示即将绘制的矩形,请动态绘制。 搜索的结果,终于找到了关键词。EntityJig随之,DrawJig浮出水面。

一.是否实时绘制EntityJig和DrawJig? 在CAD的二次开发中,有时使用JIG技术实现操作的动态性、交互,主要是在绘制特定的定制实体时,具有拖动效果,只需看得到,便于控制。

Jig循环总体上分为四个步骤,直译为:

1 )用户拖动鼠标。

2 )根据鼠标移动获得几何参数值。

3 )根据参数值更新实体数据。

4 ) WorldDraw ) )函数重画实体。

在JIG中,可以继承实体JIG (单实体绘制)和DrawJig (多实体绘制)

继承EntityJig类,并重写以获取Sampler ()从键盘或鼠标输入的参数; 如果改写Update (),将在鼠标移动过程中执行自定义绘制。

继承DrawJig类,并重写以获取Sampler ()从键盘或鼠标输入的参数; WorldDraw ) )并在鼠标移动时执行自定义绘制。

虽然EntityJig只能呈现一个实例,但DrawJig一次可以呈现多个实例,并且DrawJig类比EntityJig更方便。

这里我们决定画四条直线,形成一个矩形,继承DrawJig类。 代码写得太丑了~~~以后再来二、操作步骤1 .添加参考CAD二次开发一定要添加参考汇编~

从DrawJig代码继承的自定义RectJig类:

publicclassrectjig : draw jig { publiclineline _ 1; 公共line line _ 2; 公共line line _ 3; 公共line line _ 4; 公共点3d base pnt; public Point3d AcquirePnt; publicrectJIG(point3d_basepnt ) { line_1=new Line ); line_2=new Line (; line_3=new Line (; line_4=new Line (; BasePnt=_basePnt; } protectedoverridesamplerstatussampler (jigpromptsprompts ) jigpromptpointoptionsjppo=newjigpromptpoions; JPPO .Message='输入矩形的另一个对角点: '; JPO.user input controls=(user input controls.accept 3d coordinates )|user input controls.nullresponseaccepted|user input conted userinputconted promptpointresultpr=prompts.acquire point (jppo; if(pr.Status!=prompt status.ok (returnsamplerstatus.cancel; if(pr.value==acquirepnt )返回sampler status.no change; AcquirePnt=PR.Value; return SamplerStatus.OK; } protectedoverrideboolworlddraw { worlddrawdraw } { point 3d point _1=

new Point3d(BasePnt.X, BasePnt.Y, 0); Point3d point_2 = new Point3d(AcquirePnt.X, BasePnt.Y, 0); line_1.StartPoint = point_1; line_1.EndPoint = point_2; point_1 = new Point3d(BasePnt.X, BasePnt.Y, 0); point_2 = new Point3d(BasePnt.X, AcquirePnt.Y, 0); line_2.StartPoint = point_1; line_2.EndPoint = point_2; point_1 = new Point3d(BasePnt.X, AcquirePnt.Y, 0); point_2 = new Point3d(AcquirePnt.X, AcquirePnt.Y, 0); line_3.StartPoint = point_1; line_3.EndPoint = point_2; point_1 = new Point3d(AcquirePnt.X, BasePnt.Y, 0); point_2 = new Point3d(AcquirePnt.X, AcquirePnt.Y, 0); line_4.StartPoint = point_1; line_4.EndPoint = point_2; draw.Geometry.Draw(line_1); draw.Geometry.Draw(line_2); draw.Geometry.Draw(line_3); draw.Geometry.Draw(line_4); return true; } } 3.调用函数 public void DrawRect() { Document acDoc = Application.DocumentManager.MdiActiveDocument; Database acCurDb = acDoc.Database; PromptPointResult pPtRes; PromptPointOptions pPtOpts = new PromptPointOptions(""); pPtOpts.Message = "选取矩形起点: "; pPtRes = acDoc.Editor.GetPoint(pPtOpts); Point3d ptStart = pPtRes.Value; if (pPtRes.Status == PromptStatus.OK) { RectJig rectJig = new RectJig(ptStart); PromptResult PR = acDoc.Editor.Drag(rectJig ); if (PR.Status == PromptStatus.OK) { CADDraw.AddEntity(acCurDb, rectJig .line_1); CADDraw.AddEntity(acCurDb, rectJig .line_2); CADDraw.AddEntity(acCurDb, rectJig .line_3); CADDraw.AddEntity(acCurDb, rectJig .line_4); } } }
三、结果演示


总结

总的来说,CAD中继承jig类就可以定制自己的实体(包括文字)进行绘制或是移动、缩放等
可参考:
https://blog.csdn.net/hisinwang/article/details/78823671?utm_medium=distribute.pc_relevant.none-task-blog-baidujs_title-6&spm=1001.2101.3001.4242

Jig详细介绍可参考:
https://blog.csdn.net/net_bat/article/details/104672671?ops_request_misc=%25257B%252522request%25255Fid%252522%25253A%252522160864246916780288219693%252522%25252C%252522scm%252522%25253A%25252220140713.130102334.pc%25255Fall.%252522%25257D&request_id=160864246916780288219693&biz_id=0&utm_medium=distribute.pc_search_result.none-task-blog-2allfirst_rank_v2~rank_v29-7-104672671.first_rank_v2_pc_rank_v29&utm_term=drawjig

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。