How to find Circle from a given centre point

<?xml encoding=”UTF-8″>By Madhukar Moogala

Selection filters are very powerful device yet most of the times it is overlooked, using selection filters you can achieve many regular tasks of conditional selections.

In this snippet we will see, how you can leverage the selection filters to get a circle(s) from a given a centre point!

Do let me know if you have used conditional filters in any interesting scenario.

How do I prepare a conditional filter sequence ?

For example, we have a task to find all the MTEXT entities with particular background mask color fill

BGMASK

From the above picture, we have few MText entities with different colors, suppose if I want to get a MText with green background color fill ?

First, I would check the entity information, I can use this entity information in building a selection filter, (entget (car (entsel)))

Applying this code and pick MTEXT entity with green background mask would give me

((-1 . ) (0 . "MTEXT") (330 . ) (5 . "299") (100 . "AcDbEntity") (67 . 0) (410 . "Model") (8 . "0") (100 . "AcDbMText") (10 1495.9 1933.67 0.0) (40 . 2.5) (41 . 17.7906) (46 . 0.0) (71 . 1) (72 . 5) (1 . "AUTOCAD") (7 . "Standard") (210 0.0 0.0 1.0) (11 1.0 0.0 0.0) (42 . 16.8895) (43 . 2.58697) (50 . 0.0) (73 . 1) (44 . 1.0) (90 . 1) (63 . 3) (45 . 1.0) (441 . 0))

Now referring to MTEXT DXF reference, it is clear that DXF Code 90 is background mask on and 63 is the color when Background mask is enabled

DXF Reference

Now, to pick all MTEXT entities with background color Green

The conditional filter would be (90 . 1) (63 . 3)

This give length of entities respecting our filter

(sslength  (ssget "X"  (list  (cons 0 "MTEXT")(cons 90 1)(cons 63 3))))

Back to our topic, applying similar logic we can construct a code to filter circle based on given center point


AcDbObjectIdArray getCirclesFromAGivenPoint(AcGePoint3d centerPoint) {
AcDbObjectIdArray idArray;
ads_name ss, entName;
/*Construct a filter list*/
resbuf* filterRb = acutBuildList(RTDXF0, L"CIRCLE",
10, asDblArray(centerPoint),
RTNONE);    bool hasSS = false;
/*Make selection based on filtered list*/
if (acedSSGet(_T("_X"), NULL, NULL, filterRb, ss) == RTNORM) {
Adesk::Int32 len;
acedSSLength(ss, &len);
if (len > 0) {
hasSS = true;
/*Collect and append the objectId to an array*/
for (int nEnt = 0; nEnt < len; nEnt++)
{
if (acedSSName(ss, nEnt,entName) == RTNORM)
{
AcDbObjectId selId;
if (acdbGetObjectId(selId, entName) == Acad::eOk)
idArray.append(selId);
}
}
}
freeResbuf(&filterRb);
if (hasSS)
acedSSFree(ss);
}
return idArray;
}

Comments

11 responses to “How to find Circle from a given centre point”

  1. I can see a lot of interesting information!

  2. I was looking for a way to use dxf codes to modify some of the settings for my MTEXT object. It was harder than I anticipated, but with other people’s assistance, I finally have code that accomplishes my goals. I’m aware that this might be written in simpler code, but it fits the way my mind works.

  3. Bloxorz want to say thank you for your information

  4. JamesOneil Avatar
    JamesOneil

    Thanks for taking the time to discuss that Barclays Bank Near Me – Branch / ATM Locations
    I’d love to learn more about this area. Would you mind updating your blog post with additional insights? It will be really helpful for all of us.

  5. Charles Kraus Avatar
    Charles Kraus

    All the shapes of the success and team are fit for the working. Yes, the range of the best crypto ATM is signed for the contract. Agreement is done for the typical chain of the events for the turns for the semi-final matter for all people.

  6. GraceKelly Avatar
    GraceKelly

    Interesting situations occur when manipulating the filter amuses the user. These filters work very well in conjunction with the cuphead as it is responsive.

  7. Good post! This is a great blog that I’ll be sure to visit many more times this year. We appreciate the article.

  8. Ramselton23 Avatar
    Ramselton23

    get post

  9. The knowledge you share is excellent. It greatly aids in my comprehension of this subject.

  10. I appreciate your post because it has a lot of good information that I can absorb and learn.

  11. Conditional filters can be very useful in automating tasks and selecting specific entities based on certain criteria.

Leave a Reply to retro bowlCancel reply

Discover more from Autodesk Developer Blog

Subscribe now to keep reading and get access to the full archive.

Continue reading