.NET

Reply
Distinguished Contributor
area51visitor
Posts: 119
Registered: ‎03-05-2011
Message 1 of 10 (465 Views)
Accepted Solution

Deleting Wipeouts

465 Views, 9 Replies
03-04-2013 03:44 AM

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();
        }
    }
}

 

- Brian
"Very funny, Scotty. Now beam down my clothes."

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();
}
 
*Expert Elite*
Hallex
Posts: 1,569
Registered: ‎10-08-2008
Message 2 of 10 (445 Views)

Re: Deleting Wipeouts

03-04-2013 05:24 AM in reply to: area51visitor

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
Distinguished Contributor
area51visitor
Posts: 119
Registered: ‎03-05-2011
Message 3 of 10 (437 Views)

Re: Deleting Wipeouts

03-04-2013 06:22 AM in reply to: area51visitor

Thanks again buddy!

- Brian
"Very funny, Scotty. Now beam down my clothes."
Moderator
Alexander.Rivilis
Posts: 1,449
Registered: ‎04-09-2008
Message 4 of 10 (433 Views)

Re: Deleting Wipeouts

03-04-2013 07:17 AM 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


Пожалуйста не забывайте про Утвердить в качестве решения! Утвердить в качестве решения и Give Kudos!Баллы
Please remember to Accept Solution! Accept as Solution and Give Kudos!Kudos

Distinguished Contributor
area51visitor
Posts: 119
Registered: ‎03-05-2011
Message 5 of 10 (435 Views)

Re: Deleting Wipeouts

03-04-2013 07:20 AM in reply to: area51visitor

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.

- Brian
"Very funny, Scotty. Now beam down my clothes."
Moderator
Alexander.Rivilis
Posts: 1,449
Registered: ‎04-09-2008
Message 6 of 10 (427 Views)

Re: Deleting Wipeouts

03-04-2013 07:29 AM in reply to: area51visitor

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();
}
 

Пожалуйста не забывайте про Утвердить в качестве решения! Утвердить в качестве решения и Give Kudos!Баллы
Please remember to Accept Solution! Accept as Solution and Give Kudos!Kudos

*Expert Elite*
Hallex
Posts: 1,569
Registered: ‎10-08-2008
Message 7 of 10 (406 Views)

Re: Deleting Wipeouts

03-04-2013 12:13 PM in reply to: Alexander.Rivilis

I knew that thanks

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

 

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

_____________________________________
C6309D9E0751D165D0934D0621DFF27919
Distinguished Contributor
area51visitor
Posts: 119
Registered: ‎03-05-2011
Message 8 of 10 (401 Views)

Re: Deleting Wipeouts

03-04-2013 12:17 PM in reply to: area51visitor

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();
            }
        }
    }
}

 

 

- Brian
"Very funny, Scotty. Now beam down my clothes."
Distinguished Contributor
area51visitor
Posts: 119
Registered: ‎03-05-2011
Message 9 of 10 (396 Views)

Re: Deleting Wipeouts

03-04-2013 12:37 PM 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 :smileyhappy:

 

Thanks for the help Hallex! Always appreciated.

- Brian
"Very funny, Scotty. Now beam down my clothes."
Valued Contributor
swaywood
Posts: 91
Registered: ‎08-22-2013
Message 10 of 10 (210 Views)

Re: Deleting Wipeouts

03-06-2014 05:41 PM in reply to: area51visitor
now i am doing the same work , convert 10-years of lisp to c#.
Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Are You Going To Be @ AU 2014? Feel free to drop by our AU topic post and share your plans, plug a class that you're teaching, or simply check out who else from the community might be in attendance. Ohh and don't forgot to stop by the Autodesk Help | Learn | Collaborate booths in the Exhibit Hall and meet our community team if you get a chance!