CAD (C #) -- Introduction to entityjig & drawjig of Jig

Source: Internet
Author: User

In the secondary development of CAD, the jig technology is sometimes used to achieve dynamic and interactive operations. The most common is to customize the movement and replication of your own in CAD, of course, it is necessary to maintain the original Dynamic Display Effect in CAD.

In jig, We can inherit entityjig and drawjig. What are the differences between these two classes? What are their differences in use cases?

In fact, there are not many differences between them when operating some simple entities. To say the difference, that is, when implementing the same function, drawjig is simpler than entityjig's code. (Note: it refers to the number of objects in a simple operation ).

Entityjig: It is generally used to drag an entity. It must be an entity.

Protected override bool Update ()
{
Throw new notimplementedexception ();
}

Protected override samplerstatus sampler (jigprompts prompts)
{
Throw new notimplementedexception ();
}

Drawjig: used for dragging complex images.

Protected override bool worlddraw (Autodesk. AutoCAD. graphicsinterface. worlddraw draw)
{
Throw new notimplementedexception ();
}

Protected override samplerstatus sampler (jigprompts prompts)
{
Throw new notimplementedexception ();
}

When dragging an object, the effects of entityjig and drawjig are the same, but when we are processing the movement of multiple objects, the mouse is required to dynamically display multiple objects to be dragged in real time. entityjig cannot be implemented, but it is easy to implement drawjig. (Implemented using drawjig)

In addition, for dynamically generated entities (such as specifying a circle center and dynamically generating a circle), worldraw in drawjig can be flexibly controlled for generation.

In contrast, do you find that drawjig is superior to entityjig (personal understanding ).

The following code is provided:

Code

1 # region drawjig dynamically drag multiple objects
2 public class drawjigent: drawjig
3 {
4 // variable
5 point3d oldpt; // the position before the object is moved.
6 point3d newpt; // position after moving the object
7 vector3d V; // vector of object movement
8
9 list <entity> ents = new list <entity> ();
10 list <point3d> oldpts = new list <point3d> ();
11 Public drawjigent (list <entity> ENTs)
12 {
13 oldpt = point3d. origin;
14 newpt = point3d. origin;
15 V = new vector3d ();
16 this. ents = ENTs;
17
18 Autodesk. AutoCAD. databaseservices. entity ent = ents [0];
19 if (ent is blockreference)
20 {
21 blockreference BR = ent as blockreference;
22 oldpt = Br. position;
23}
24
25 For (INT I = 1; I <ENTs. Count; I ++)
26 {
27 if (ENTs [I] Is blockreference)
28 {
29 blockreference BR = ents [I] As blockreference;
30 oldpts. Add (Br. position );
31}
32}
33}
34
35 // update
36 protected override bool worlddraw (Autodesk. AutoCAD. graphicsinterface. worlddraw draw)
37 {
38 entity ent = ents [0];
39 Ent. upgradeopen ();
40 if (ent is blockreference)
41 {
42 blockreference BR = ent as blockreference;
43 Br. Position = newpt;
44 draw. Geometry. Draw (BR );
45}
46
47 v = newpt. getvectorto (oldpt );
48
49 for (INT I = 1; I <ENTs. Count; I ++)
50 {
51 entity = ents [I];
52 entity. upgradeopen ();
53 If (entity is blockreference)
54 {
55 blockreference BR = entity as blockreference;
56 Br. Position = oldpts [I-1] + V;
57 draw. Geometry. Draw (entity );
58}
59}
60
61 Return true;
62}
63 // sampling Function
64 protected override samplerstatus sampler (jigprompts prompts)
65 {
66 jigpromptoptions opt = new jigpromptoptions ();
67 opt. userinputcontrols = userinputcontrols. accept3dcoordinates | userinputcontrols. nonegativeresponseaccepted | userinputcontrols. nullresponseaccepted;
68 opt. usebasepoint = true;
69 opt. cursor = cursortype. rubberband;
70 opt. basepoint = oldpt;
71 opt. Message = "select the destination to be moved ";
72
73 promptpointresult res = prompts. acquirepoint (OPT );
74 if (promptstatus. OK = res. Status)
75 {
76 if (res. value = newpt)
77 {
78 return samplerstatus. nochange;
79}
80 newpt = res. value;
81}
82 else
83 {
84 return samplerstatus. Cancel;
85}
86 return samplerstatus. OK;
87}
88}
89 # endregion

 

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.