Selecting and editing custom entities in MultiCAD.NET

00

In the previous post we discussed the process for creating custom entities in the MultiCAD.NET API, and described the CustomObjects example from the SDK. In this post we’re going to focus on the issue of selecting custom entities of the same type in the drawing.

The CustomObjects example creates custom entities that display as framed text strings:

TextInBox entities

TextInBox entities with initial text strings

We’ll extend the code for the CustomObjects example by adding functionality to searching for one or more of these entities and changing the text for each of them.

In MultiCAD.NET, when selecting a single object in the drawing, the object manager’s method SelectObject() is used. The method has the following signatures:

Both methods allow the user to select an object based on a prompt shown in the command line. The second method adds an additional parameter for the coordinates of the selection point.

For selecting multiple objects, the following methods are used:

The first method selects drawing objects using a specific filter, the second one shows a prompt in the command line and allows the user to pick objects by themself.

The filter is represented by an ObjectFilter object and defines the selection criteria: object type, documents, layers, sheets or area for searching objects. In the following example, the SelectCircles command gets a list of circle objects that are on the current sheet and intersect a specified rectangular area:

To find all circle entities from the entire drawing (not only on the current sheet), the drawing’s document should be set as a search area:

The second method allows the user to select entities manually instead of using filters, but we need to make sure the user has selected only entities of desired type.

Here we create a new command called TextInBoxEdit that allows user to select a set of any entities, then filters out only TextInBox entities from the set and changes text for all of them:

Let’s see how it works.

The command prompts the user to select entities on the drawing:

05_en

User-selected objects

After the command’s execution, the text strings have been changed in all selected TextInBox entities:

04

TextInBox entities with changed text strings

Leave a Reply