简体   繁体   中英

How to remove/locate invalid object in my dxf file?

When I open a particular Dxf file in LibreCAD, the command line dialog box in libreCAD says :

Invalid objects removed : 1

I want to detect this invalid object in my dxf file and remove it. When does an object become invalid? What does an invalid object mean?

Since I didn't receive any answers overe here, I decided to dig into the libreCAD source code, and found this in rs_graphic.cpp :

/**
 * Removes invalid objects.
 * @return how many objects were removed
 */
int RS_Graphic::clean()
{
    // author: ravas

    int how_many = 0;

    foreach (RS_Entity* e, entities)
    {
        if    (e->getMin().x > e->getMax().x
            || e->getMin().y > e->getMax().y
            || e->getMin().x > RS_MAXDOUBLE
            || e->getMax().x > RS_MAXDOUBLE
            || e->getMin().x < RS_MINDOUBLE
            || e->getMax().x < RS_MINDOUBLE
            || e->getMin().y > RS_MAXDOUBLE
            || e->getMax().y > RS_MAXDOUBLE
            || e->getMin().y < RS_MINDOUBLE
            || e->getMax().y < RS_MINDOUBLE)
        {
            removeEntity(e);
            how_many += 1;
        }
    }

The above code is self-explanatory and I hope this helps anyone who wonders the same question in future.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM