.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Deleting Wipeouts

9 REPLIES 9
SOLVED
Reply
Message 1 of 10
brianchapmandesign
1072 Views, 9 Replies

Deleting Wipeouts

Is this correct?

 

namespace BCCDELWIPOUT
{
    public class DraftingTools
    {

        [CommandMethod("BCC:WOUT")]

        public static void BCCDELETEWIPOUT()
        {
            Document doc = Application.DocumentManager.MdiActiveDocument;
            Database db = doc.Database;
            Transaction tr = db.TransactionManager.StartTransaction();

            using (tr)
            {
                BlockTable bt = tr.GetObject(db.BlockTableId, OpenMode.ForRead) as BlockTable;
                foreach (ObjectId objId in bt)
                {
                    BlockTableRecord btr = objId.GetObject(OpenMode.ForRead) as BlockTableRecord;

                    foreach (ObjectId btrObjId in btr)
                    {
                        Entity ent = btrObjId.GetObject(OpenMode.ForRead) as Entity;
                        if (ent is Wipeout)
                        {
                            ent.UpgradeOpen();
                            {
                                ent.Erase();
                            }
                        }
                    }
                }
            }
            tr.Commit();
        }
    }
}

 


"Very funny, Scotty. Now beam down my clothes.
9 REPLIES 9
Message 2 of 10
Hallex
in reply to: brianchapmandesign

No,

Wipeout is nothing but closed lwpolyline

with number of verices more than 3 items,

with every bulged segments,

so you can check all these properties to make

sure if you select wipeout

_____________________________________
C6309D9E0751D165D0934D0621DFF27919
Message 3 of 10

Thanks again buddy!


"Very funny, Scotty. Now beam down my clothes.
Message 4 of 10
Alexander.Rivilis
in reply to: Hallex


@Hallex wrote:
Wipeout is nothing but closed lwpolyline

with number of verices more than 3 items,

with every bulged segments,

so you can check all these properties to make

sure if you select wipeout


Oleg! Are you sure??? Wipeout is Wipeout:


04-03-2013 17-14-55.png

Відповідь корисна? Клікніть на "ВПОДОБАЙКУ" цім повідомленням! | Do you find the posts helpful? "LIKE" these posts!
Находите сообщения полезными? Поставьте "НРАВИТСЯ" этим сообщениям!
На ваше запитання відповіли? Натисніть кнопку "ПРИЙНЯТИ РІШЕННЯ" | Have your question been answered successfully? Click "ACCEPT SOLUTION" button.
На ваш вопрос успешно ответили? Нажмите кнопку "УТВЕРДИТЬ РЕШЕНИЕ"


Alexander Rivilis / Александр Ривилис / Олександр Рівіліс
Programmer & Teacher & Helper / Программист - Учитель - Помощник / Програміст - вчитель - помічник
Facebook | Twitter | LinkedIn
Expert Elite Member

Message 5 of 10

Thanks Alexander.  Don't think this was always exposed to the API, correct? Might be why the suggestion.  I'm using 2012 Civil 3D... think it will work...

 

I just don't know the right way to collect the Wipeouts... as you can see in my code...  I'm doing something wrong but not sure what.  One thing is I don't think I have to ent.UpgradeOpen, I think I can just ent.erase but I'm crashing so there must be something else wrong.


"Very funny, Scotty. Now beam down my clothes.
Message 6 of 10


@bcinnv wrote:

...Don't think this was always exposed to the API, correct?...


IMHO class Wipeout is exposed with AutoCAD .NET API since AutoCAD 2008.

 


bcinnv wrote:

I just don't know the right way to collect the Wipeouts... as you can see in my code...  I'm doing something wrong but not sure what.  One thing is I don't think I have to ent.UpgradeOpen, I think I can just ent.erase but I'm crashing so there must be something else wrong.


Try replace code:

using (tr)
{
     //.......
}
tr.Commit();


with:

 

using (tr)
{
     //.......
     tr.Commit();
}
 

Відповідь корисна? Клікніть на "ВПОДОБАЙКУ" цім повідомленням! | Do you find the posts helpful? "LIKE" these posts!
Находите сообщения полезными? Поставьте "НРАВИТСЯ" этим сообщениям!
На ваше запитання відповіли? Натисніть кнопку "ПРИЙНЯТИ РІШЕННЯ" | Have your question been answered successfully? Click "ACCEPT SOLUTION" button.
На ваш вопрос успешно ответили? Нажмите кнопку "УТВЕРДИТЬ РЕШЕНИЕ"


Alexander Rivilis / Александр Ривилис / Олександр Рівіліс
Programmer & Teacher & Helper / Программист - Учитель - Помощник / Програміст - вчитель - помічник
Facebook | Twitter | LinkedIn
Expert Elite Member

Message 7 of 10
Hallex
in reply to: Alexander.Rivilis

I knew that thanks

But why this way it's not working this way?

 

(ssget "_X" '(( 0 . "wipeout")))

_____________________________________
C6309D9E0751D165D0934D0621DFF27919
Message 8 of 10

Thanks Alexander you were correct! The placement of the TR was the problem.  Updated code below:

 

// delete wipeouts

namespace BCCDELWIPOUT
{
    public class DraftingTools
    {

        [CommandMethod("BCC:WOUT")]

        public static void BCCDELETEWIPOUT()
        {
            Document doc = Application.DocumentManager.MdiActiveDocument;
            Database db = doc.Database;
            Transaction tr = db.TransactionManager.StartTransaction();

            using (tr)
            {
                BlockTable bt = tr.GetObject(db.BlockTableId, OpenMode.ForWrite) as BlockTable;
                foreach (ObjectId objId in bt)
                {
                    BlockTableRecord btr = objId.GetObject(OpenMode.ForWrite) as BlockTableRecord;

                    foreach (ObjectId btrObjId in btr)
                    {
                        Entity ent = btrObjId.GetObject(OpenMode.ForWrite) as Entity;
                        if (ent is Wipeout)
                        {
                            ent.Erase();
                            
                        }
                    }
                } tr.Commit();
            }
        }
    }
}

 

 


"Very funny, Scotty. Now beam down my clothes.
Message 9 of 10
brianchapmandesign
in reply to: Hallex

Thanks! That was the way I did it in Lisp. I have decided to convert 10 years of lisp routines I've collected / created into C#, somewhat to learn, but also because I like the better performance with .net.  There is such little material about C# out there than there was .lsp it's considerably harder, but always enjoy a challenge 🙂

 

Thanks for the help Hallex! Always appreciated.


"Very funny, Scotty. Now beam down my clothes.
Message 10 of 10

now i am doing the same work , convert 10-years of lisp to c#.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost