TheSwamp

Code Red => .NET => Topic started by: Viktor on September 29, 2008, 04:37:13 PM

Title: Skip objects inside a block while checking additions with ObjectAppended
Post by: Viktor on September 29, 2008, 04:37:13 PM
Hi guys, autodesk forums are really messed up these days so I thought I'd venture back here :)

My problem:
I'm adding all items to a treeview control as they are being added to the drawing. Well, when you insert a block, that means that every line in that block will also be added to the database and trigger objectappended event. I don't want to show all the items of the block, just the block on the treeview, is there a way to filter them out?

Thanks,
Viktor.
Title: Re: Skip objects inside a block while checking additions with ObjectAppended
Post by: It's Alive! on September 29, 2008, 05:02:47 PM
How about checking the ownerid ?
Title: Re: Skip objects inside a block while checking additions with ObjectAppended
Post by: T.Willey on September 29, 2008, 05:03:36 PM
Just some ideas.

In lisp there is a begin block ( and end block ) object.  Does .Net have this?  If so, maybe this will tell you where the beginning is and the ending.

If not begin / end block, then maybe the owner of the line is not the model / paper space block, but a different one.  Maybe you could check that.
Title: Re: Skip objects inside a block while checking additions with ObjectAppended
Post by: Viktor on September 29, 2008, 05:40:47 PM
Yes, BlockBegin and BlockEnd is there in .net, but unfortunately all the objects inside the block append after BlockEnd.
Title: Re: Skip objects inside a block while checking additions with ObjectAppended
Post by: Kerry on September 29, 2008, 05:49:58 PM
Hi guys, autodesk forums are really messed up these days so I thought I'd venture back here :)

My problem:
I'm adding all items to a treeview control as they are being added to the drawing. Well, when you insert a block, that means that every line in that block will also be added to the database and trigger objectappended event. I don't want to show all the items of the block, just the block on the treeview, is there a way to filter them out?

Thanks,
Viktor.

Viktor,
How are you determining what to add to the treeview ?
Each block has a unique identifier, so you must be burrowing down into the block entitys from the blockTable instead of using the block ID in the modelspace..

difficult to know where your error is without code ...
Title: Re: Skip objects inside a block while checking additions with ObjectAppended
Post by: T.Willey on September 29, 2008, 06:22:04 PM
With lisp ( easier and quicker for me to test and write ) it seems like the block is made ( begin ), then the end block, then the block record which owns both.  The an ellipse ( in this case the block is an ellipse and a line ) and the owner is the block record, and then the line ( same as the ellipse ).  When you get into blocks with text and attributes or dimensions, then you will have a little harder time, as the styles and such need to be created if not in the database already.  Here is a quote from the command line that shows what I'm talking about.

Quote
"BLOCK"
(-1 . <Entity name: 7ed2d918>)
(0 . "BLOCK")
(330 . <Entity name: 7ed2d900>)
(5 . "1C3")
(100 . "AcDbEntity")
(67 . 0)
(8 . "0")
(100 . "AcDbBlockBegin")
(70 . 0)
(10 0.0 0.0 0.0)
(-2 . <Entity name: 7ed2d908>)
(2 . "ECLD")
(1 . "")


"ENDBLK"
(-1 . <Entity name: 7ed2d920>)
(0 . "ENDBLK")
(330 . <Entity name: 7ed2d900>)
(5 . "1C4")
(100 . "AcDbEntity")
(67 . 0)
(8 . "0")
(100 . "AcDbBlockEnd")


"BLOCK_RECORD"
(-1 . <Entity name: 7ed2d900>)
(0 . "BLOCK_RECORD")
(330 . <Entity name: 7ed10c08>)
(5 . "1C0")
(100 . "AcDbSymbolTableRecord")
(100 . "AcDbBlockTableRecord")
(2 . "ECLD")
(360 . <Entity name: 7ed2d918>)
(340 . <Entity name: 0>)
"ELLIPSE"
(-1 . <Entity name: 7ed2d908>)
(0 . "ELLIPSE")
(330 . <Entity name: 7ed2d900>)
(5 . "1C1")
(100 . "AcDbEntity")
(67 . 0)
(8 . "0")
(100 . "AcDbEllipse")
(10 0.0 0.0 0.0)
(11 0.5 -6.12303e-017 0.0)
(210 0.0 0.0 1.0)
(40 . 0.35795)
(41 . 0.0)
(42 . 6.28319)


"LINE"
(-1 . <Entity name: 7ed2d910>)
(0 . "LINE")
(330 . <Entity name: 7ed2d900>)
(5 . "1C2")
(100 . "AcDbEntity")
(67 . 0)
(8 . "0")
(100 . "AcDbLine")
(10 -0.5 6.12303e-017 0.0)
(11 -1.0 1.22461e-016 0.0)
(210 0.0 0.0 1.0)
Title: Re: Skip objects inside a block while checking additions with ObjectAppended
Post by: T.Willey on September 29, 2008, 06:38:54 PM
Another idea.  Make an ObjectIdCollection of all the layout's block table records.  And then just see if the owner id is a member of the collection.  If so add it to the treeview, if not skip it.

With this you might have to have an event in case a layout gets added to the drawing though.
Title: Re: Skip objects inside a block while checking additions with ObjectAppended
Post by: Viktor on September 29, 2008, 06:42:44 PM
(http://www.theswamp.org/screens/Viktor_events.bmp)

That's what I'm getting on a new drawing with one block. The code I'm using to add item to the treeview is this:

        Private Sub callback_objectAppended(ByVal sender As Object, ByVal e As ObjectEventArgs)
            Dim newnode As System.Windows.Forms.TreeNode = myControl.TreeView1.Nodes.Add(e.DBObject.GetType().ToString)
            Dim objName As String = e.DBObject.GetType().Name
            Select Case objName
                Case Is = "Line"
                    MsgBox(e.DBObject.GetType().ToString)
                Case Is = "AcDbLine"
                Case Is = "BlockTableRecord"
                    MsgBox(e.DBObject.GetType().ToString)
            End Select
        End Sub

The idea is that I would get the needed data based off of what type of object it is.

Now that I think more about this, should I be getting the objectID of the object and then getting the data from the db once the object is in? Instead of trying to intercept everything?
Title: Re: Skip objects inside a block while checking additions with ObjectAppended
Post by: Kerry on September 29, 2008, 06:49:18 PM

Now that I think more about this, should I be getting the objectID of the object and then getting the data from the db once the object is in? Instead of trying to intercept everything?

I would.
Title: Re: Skip objects inside a block while checking additions with ObjectAppended
Post by: T.Willey on September 29, 2008, 06:51:48 PM
I think it depends on what you want.  What is the routine supposed to do in the end?
Title: Re: Skip objects inside a block while checking additions with ObjectAppended
Post by: Kerry on September 29, 2008, 07:16:00 PM

Having a quick think about this.

Is the list meant to be fully dynamic, and only showing certain classes of objects ?

How are you handling erased objects .... ? ..... I would imagine you'd need to keep a listing of the ObjectID's that the list represents to allow removal of the correct entry at erasure ?

Also, are you generating the list for existing objects in the DB when the app fires up ?
Title: Re: Skip objects inside a block while checking additions with ObjectAppended
Post by: Viktor on September 29, 2008, 08:26:06 PM

Having a quick think about this.

Is the list meant to be fully dynamic, and only showing certain classes of objects ?

How are you handling erased objects .... ? ..... I would imagine you'd need to keep a listing of the ObjectID's that the list represents to allow removal of the correct entry at erasure ?

Also, are you generating the list for existing objects in the DB when the app fires up ?


Ah, so many questions so little time. This is a much more lively forum than autodesk one.

Well, first off, this product is supposed to audit ongoing work, or audit entire drawing. It is in a palette. I have another application that allows a standards administrator to build a database containing all kinds of standards that are to be applied to drawings. For example, all blocks with names XXXX-XX are to be on XXXX layer. It goes much deeper, but anyway, this tool then is the end-user tool that would/could run all the time and as the user places a block or draws a line or adds text it would check the DB and if it confirms to standards it would not do anything. But if it failed it would add to the proper category and add a comment on what is wrong with that item.

Also, it would run a report on entire drawing when required.

Yes, I will have to store object ID's somehow as well, so that deleting, updating, undoing can be taken care of as well. Sounds like I have to go back to the cave to do more thinking about this.
Title: Re: Skip objects inside a block while checking additions with ObjectAppended
Post by: T.Willey on September 30, 2008, 11:10:58 AM
If this information is to be stored over different sessions of the drawing ( closing and opening ) then I would store the handle in a dictionary that resides within the drawing.

Do your standards say that items within a block have to be a certain style ( bylayer or byblock )?  If so, then I think you need to catch them also, not just the ones added to the model / paper spaces.

With this being said, I think the best way for you to check items is to use the owner objectId, and then do what you need to do to the items per where they are placed; either in a block table record of a block or layout.
Title: Re: Skip objects inside a block while checking additions with ObjectAppended
Post by: Glenn R on September 30, 2008, 06:12:34 PM
CAD Standards (DWS files) anyone...anyone...?

Also, if you must pursue this route, I seem to remember an Adesk sample that did this (in a palette even)...maybe MgdArxDbg...can't quite remember...I'm sure I've seen one though...
Title: Re: Skip objects inside a block while checking additions with ObjectAppended
Post by: Glenn R on September 30, 2008, 06:15:13 PM
BTW, the easiest way to see the order of appended objects, is to fire up ARXDBG and enable it's dbase reactors, then insert a block for instance..........
Title: Re: Skip objects inside a block while checking additions with ObjectAppended
Post by: Viktor on October 01, 2008, 03:09:47 PM
CAD Standards (DWS files) anyone...anyone...?

Also, if you must pursue this route, I seem to remember an Adesk sample that did this (in a palette even)...maybe MgdArxDbg...can't quite remember...I'm sure I've seen one though...

We utilize the dws file to its extents, but you can't program logic into a dws file. When we have to send 80% of our work to consultants all across USA, we want to make sure that all follow our standards as much as they can.

But I will have to look into this mgdarxdbg thing you're talking about.

Thanks,
Viktor.


Title: Re: Skip objects inside a block while checking additions with ObjectAppended
Post by: Viktor on October 01, 2008, 03:13:38 PM
BTW, the easiest way to see the order of appended objects, is to fire up ARXDBG and enable it's dbase reactors, then insert a block for instance..........

Since you brought up the ObjectArx SDK, can you explain how I would "fire up" something out of that package? I downloaded it a while back and noticed that most everything in there is c++, I don't have a full Visual Studio package to compile those projects, I know there's ways to compile C# or VB.net projects outside of Visual Studio, but how do I do a C++ project? And should I?

Thanks,
Viktor.
Title: Re: Skip objects inside a block while checking additions with ObjectAppended
Post by: Spike Wilbury on October 01, 2008, 07:04:17 PM
BTW, the easiest way to see the order of appended objects, is to fire up ARXDBG and enable it's dbase reactors, then insert a block for instance..........

Since you brought up the ObjectArx SDK, can you explain how I would "fire up" something out of that package? I downloaded it a while back and noticed that most everything in there is c++, I don't have a full Visual Studio package to compile those projects, I know there's ways to compile C# or VB.net projects outside of Visual Studio, but how do I do a C++ project? And should I?

Thanks,
Viktor.

The SDK ObjectARX samples are basically ready for compile - but it requires VS2002 or VS2005 (no express versions) depending on your AutoCAD version.

Below is the version for 2007:
Title: Re: Skip objects inside a block while checking additions with ObjectAppended
Post by: Viktor on October 02, 2008, 08:42:30 PM
BTW, the easiest way to see the order of appended objects, is to fire up ARXDBG and enable it's dbase reactors, then insert a block for instance..........

Since you brought up the ObjectArx SDK, can you explain how I would "fire up" something out of that package? I downloaded it a while back and noticed that most everything in there is c++, I don't have a full Visual Studio package to compile those projects, I know there's ways to compile C# or VB.net projects outside of Visual Studio, but how do I do a C++ project? And should I?

Thanks,
Viktor.

The SDK ObjectARX samples are basically ready for compile - but it requires VS2002 or VS2005 (no express versions) depending on your AutoCAD version.

Below is the version for 2007:


Thanks Luis!

Yea, they won't let a cad junkie like myself have a copy of VS, I had to pull all the guns out to get the express suites.

Thanks again.