Author Topic: Skip objects inside a block while checking additions with ObjectAppended  (Read 7520 times)

0 Members and 1 Guest are viewing this topic.

Viktor

  • Guest
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.

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8705
  • AKA Daniel
Re: Skip objects inside a block while checking additions with ObjectAppended
« Reply #1 on: September 29, 2008, 05:02:47 PM »
How about checking the ownerid ?

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Skip objects inside a block while checking additions with ObjectAppended
« Reply #2 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.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

Viktor

  • Guest
Re: Skip objects inside a block while checking additions with ObjectAppended
« Reply #3 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.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Skip objects inside a block while checking additions with ObjectAppended
« Reply #4 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 ...
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Skip objects inside a block while checking additions with ObjectAppended
« Reply #5 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)
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Skip objects inside a block while checking additions with ObjectAppended
« Reply #6 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.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

Viktor

  • Guest
Re: Skip objects inside a block while checking additions with ObjectAppended
« Reply #7 on: September 29, 2008, 06:42:44 PM »


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?

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Skip objects inside a block while checking additions with ObjectAppended
« Reply #8 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.
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Skip objects inside a block while checking additions with ObjectAppended
« Reply #9 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?
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Skip objects inside a block while checking additions with ObjectAppended
« Reply #10 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 ?
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

Viktor

  • Guest
Re: Skip objects inside a block while checking additions with ObjectAppended
« Reply #11 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.

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Skip objects inside a block while checking additions with ObjectAppended
« Reply #12 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.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

Glenn R

  • Guest
Re: Skip objects inside a block while checking additions with ObjectAppended
« Reply #13 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...

Glenn R

  • Guest
Re: Skip objects inside a block while checking additions with ObjectAppended
« Reply #14 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..........