CAD controls using tutorials to customize the implementation of entities

Source: Internet
Author: User

Implementation of custom Entities

1. Custom Entities ... 3

1.1 Description ... 3

Type information for class 1.2 ... 3

1.3 Worlddraw. 4

1.4 Getgrippoints 4

1.5 Movegrippointsat 5

1.6 Getgeomextents 6

1.7 getosnappoints 6

1.8 Explode. 7

1.9 Dwginfields 8

1.10 Dwgoutfields 9

1.11 Control Routines Description ... 9


1, custom Entity 1.1 description

The Mcdbentity control supports custom entity functionality and can inherit its own entity from the, and implement related virtual functions in the custom entity class to implement the custom functions of the entity.

Type information for class 1.2

Use the Mcrx_declare_members macro to define the type information function for a class, and the first parameter of the macro is the class name of the class. Use for example:

Mcrx_declare_members (Clinkline);

Use the Acrx_dxf_define_members macro to implement the type information function of the class. Macro definition parameters are used as follows:

Acrx_dxf_define_members (Clinkline, Mcdbentity,

Acdb::kdhl_current,acdb::kmreleasecurrent,

acdbproxyentity::kallallowedbits,_t ("Linkline"),

_t ("Mxdrawobjtest Custom Entity"));

Clinkline the class name of the custom entity

Mcdbenity base class for custom entities

Acdb::kdhl_current Current file version

Acdb::kmreleasecurrent Current Control version

ACDBPROXYENTITY::KALLALLOWEDBITS Agent Entity Processing flags

_t ("Linkline") Dfx0 group code corresponding value

_t ("Mxdrawobjtest Custom Entity") class description

When the program starts, call the Rxinit function, and the type information of the custom entity is registered to the system, using for example:

BOOL ccustomentityapp::initinstance ()

{

.....

Register the custom entity class information.

Clinkblock::rxinit ();

Clinkline::rxinit ();

1.3 Worlddraw

Reload the virtual function to draw the display effect of the custom entity

VC Interface:

Adesk::boolean worlddraw (acgiworlddraw * wd);

Parameters:

WD displays the drawn context object

Reference routines:

Adesk::boolean Clinkline::worlddraw (Acgiworlddraw * wd)

{

Assertreadenabled ();

Wd->geometry (). Line (M_start,m_end);

Std::auto_ptr<acdbtext>sptext (Getdimtext ());

Sptext->worlddraw (WD);

Returnadesk::ktrue;

}

1.4 Getgrippoints

Overloads the virtual function to return a custom edit grip

VC Interface:

Virtualacad::errorstatus getgrippoints(

acgepoint3darray& grippoints,

acgeintarray& osnapmodes,

acgeintarray& geomids) const;

Parameters:

Grippoints return to pinch point

Osnapmodes not used

Geomids not used

Reference routines:

Acad::errorstatus clinkline::getgrippoints (

acgepoint3darray& Grippoints,

acgeintarray& Osnapmodes,

acgeintarray& geomids) const

{

Assertreadenabled ();

Grippoints.append (M_start); Return to start point grip

Grippoints.append (M_end); Return to end point grip

Grippoints.append (m_start+ (M_end-m_start)/2.0); Returns the midpoint grip point.

Returnacad::eok;

}

1.5 Movegrippointsat

Overloads the virtual function to handle the grip edit result.

VC Interface:

Virtual acad::errorstatusMovegrippointsat(

Const acgeintarray& Indices,

constacgevector3d& offset);

Parameters:

The indices indices [0] parameter is the input to the edited grip index, and the other array elements are temporarily unused.

Offset grip Edit Offsets

Reference routines:

Acad::errorstatusclinkline::movegrippointsat (const acgeintarray& Indices,

Const acgevector3d& Offset)

{

Assertwriteenabled ();

int IIndex =indices[0];

Switch (IINDEX)

{

Case 0:

m_start= M_start + offset; Start Point is edited

Break

Case 1:

m_end= m_end + offset; End Point is edited

Break

Case 2:

m_start= M_start + offset; Midpoint is edited

m_end= m_end + offset; Midpoint is edited

Break

}

Returnmcad::eok;

}

1.6 getgeomextents

Overloads the virtual function to return the outsourced rectangle for the custom entity

VC Interface:

Virtual Acad::errorstatus getgeomextents(

acdbextents& extents) const;

Parameters:

extents Returns the custom Entity outsourcing rectangle box.

Reference routines:

Acad::errorstatus clinkline::getgeomextents (acdbextents& extents) const

{

Assertreadenabled ();

Extents.set (M_start,m_end);

Returnmcad::eok;

}

1.7 getosnappoints

Overloads the virtual function to return the snap point of the custom entity

VC Interface:

Virtualacad::errorstatus getosnappoints (

acdb::osnapmode Osnapmode,

int Gsselectionmark,

constacgepoint3d& pickpoint,

constacgepoint3d& lastpoint,

const acgematrix3d& Viewxform,

acgepoint3darray& snappoints,

acdbintarray& geomids) const;

Parameters:

Osnapmode snap point type, which allows you to determine what type of snap point to return

Gsselectionmark not used

Pickpoint Current input Point

Lastpoint the last input point

Viewxform not used

snappoints return to Snap point

Geomids not used

Reference routines:

Acad::errorstatus clinkline::getosnappoints (

Acdb::osnapmode Osnapmode,

int Gsselectionmark,

constacgepoint3d& Pickpoint,

constacgepoint3d& Lastpoint,

constacgematrix3d& Viewxform,

acgepoint3darray& Snappoints,

acdbintarray& geomids) const

{

Assertreadenabled ();

if (osnapmode== mcdb::kosmodeend)

{

return endpoints.

Snappoints.append (M_start);

Snappoints.append (M_end);

}

ElseIf (Osnapmode = = Mcdb::kosmodemid)

{

The midpoint is returned.

Snappoints.append (m_start+ (M_end-m_start)/2.0);

}

Returnmcad::eok;

}

1.8 Explode

Overloading the virtual function returns the entity that the custom entity was broken in, and in the control, when the custom entity is saved in the DWG diagram, it is saved using a block reference, which the control uses to get the entity data for the custom entity in the block reference.

VC Interface:

Virtual Acad::errorstatus explode(

acdbvoidptrarray& entitySet) const;

Parameters:

EntitySet returns the underlying entity after breaking. The Entity pointer Memory control is disposed.

Reference routines:

Acad::errorstatus Clinkline::explode (acdbvoidptrarray& entitySet) const

{

Assertreadenabled ();

Acdbline*pline = new Acdbline (m_start,m_end);

Entityset.append (PLine);

Entityset.append (Getdimtext ());

Returnacad::eok;

}

1.9 Dwginfields

Overloads the virtual function, responds to the control system, reads the custom entity data, and invokes the function in places such as reading entities from a file, copying entities, and so on.

VC Interface:

virtualacad::errorstatusdwginfields(acdbdwgfiler* pfiler);

Parameters:

The Pfiler data archive object, in this function, uses the object to read the data.

Reference routines:

Acad::errorstatus clinkline::d wginfields (acdbdwgfiler* pfiler)

{

Assertwriteenabled ();

if (Pfiler->filertype ()! = Mcdb::kcustomentityfilefiler)

{

mcad::errorstatuses;

if (es = mcdbentity::d wginfields (pfiler))! = Mcad::eok)

{

Returnes;

}

}

int lvar = 1;

Pfiler->readint (&lvar);

Pfiler->readpoint3d (&m_start);

Pfiler->readpoint3d (&m_end);

Returnmcad::eok;

}

1.10 Dwgoutfields

Overloads the virtual function, responds to the control system, writes custom entity data, and calls the function when the entity is written to the file, such as the copy entity.

VC Interface:

virtualacad::errorstatusdwgoutfields(acdbdwgfiler* pfiler) const;

Parameters:

The Pfiler data archive object, in this function, uses the object to write data.

Reference routines:

Acad::errorstatusclinkline::d wgoutfields (acdbdwgfiler* pfiler) const

{

Assertreadenabled ();

if (Pfiler->filertype ()! = Mcdb::kcustomentityfilefiler)

{

mcad::errorstatuses;

if (es = mcdbentity::d wgoutfields (pfiler))! = Mcad::eok)

{

Returnes;

}

}

Pfiler->writeint (linkline_version);

Pfiler->writepoint3d (M_start);

Pfiler->writepoint3d (M_end);

Returnmcad::eok;

}

1.11 Control Routines Description

The Samples\customentitycustomentity.sln routine, under the control installation directory, demonstrates the custom manifestation. Implement connection blocks in routines Clinkblock custom entities, Clinkline custom entities,

The Clinkblock class display is displayed through a block reference, and the drawing snap point is determined by the block attribute definition text in the block record, and when the entity is edited, the connection lines connected to the entity are automatically moved to achieve a dynamic effect.

The Clinkline class implements a segment entity function with a length callout function.

CAD controls using tutorials to customize the implementation of entities

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.