Author Topic: Cloned ObjectIDs  (Read 2129 times)

0 Members and 1 Guest are viewing this topic.

SamR

  • Mosquito
  • Posts: 15
Cloned ObjectIDs
« on: August 26, 2011, 12:45:44 PM »
Hi all.
Hoping someone can help or tell me that this is not possible.
I have an application that must to do it and I'm sure I'm couldn't be treading new ground.

I need to review the cloned ObjectIDs before or after the operation. Apparently something like this:

Public Sub db_BeginDeepClone(ByVal sender As Object, ByVal e As Autodesk.AutoCAD.DatabaseServices.IdMappingEventArgs)
    Dim ed As Editor = Application.DocumentManager.MdiActiveDocument.Editor
    For Each idp As IdPair In e.IdMapping
        If idp.IsPrimary AndAlso idp.IsCloned Then
            ed.WriteMessage("{0}Key:{1} Value{2}", Environment.NewLine, idp.Key, idp.Value)
            Dim br As BlockReference = DirectCast(trans.GetObject(idp.Value, OpenMode.ForRead, False), BlockReference)
        End If
    Next
End Sub

Jeff H

  • Needs a day job
  • Posts: 6150
Re: Cloned ObjectIDs
« Reply #1 on: August 26, 2011, 02:04:19 PM »
Could you explain in more detail what you are trying to acomplish or what the end result is.
 
Because there are alot of factors that will effect your results.
 
For example:
BeginDeepClone is called before the translation of the objectIDs.
 
There are many more factors like cloning BlockTableRecords, hard soft ownership, etc..........
 
There is a section in arxdoc.chm on deepcloning. 

SamR

  • Mosquito
  • Posts: 15
Re: Cloned ObjectIDs
« Reply #2 on: August 27, 2011, 05:45:37 AM »
I'm using a dictionary to keep track of entities used by my app (a tree that I can easily manipulate and collect data from). Copying entities is the only problem because I don't know what has been copied and what to add to the dictionary.


Jeff H

  • Needs a day job
  • Posts: 6150
Re: Cloned ObjectIDs
« Reply #3 on: August 27, 2011, 12:09:29 PM »
So you are trying to keep track of just entites(basiclly anything you can see)?
or you need extension dictionary's, xdata etc..... that are copied?
 
Are you trying to keep track of every entity like lines, circles etc......
or certain ones your app adds and you want to keep up with ones that the user copys?
 
Does it need to keep up with ones that can copied and pasted in different drawings?
 
etc...
etc....
etc.....
etc....

and
Welcome to the Swamp!

SamR

  • Mosquito
  • Posts: 15
Re: Cloned ObjectIDs
« Reply #4 on: August 28, 2011, 12:48:43 PM »
Thankyou!

My first problem is to keep track of the visible entities being copied. I need to keep an eye on the objects inserted in the drawing by the app (blocks and polylines).

I store all entity handles used by the app as entries in a dictionary tree and at the top of each tree level is an xrecord containing data for the group of entities.
I don't have any xdata attached to the entities at the moment. The data for each entity is not repeated and more accessible in the way I have done it I think.

Copying between drawings is the next hurdle but I can't control the process in the active drawing without using an overrule. The way I am using the clone overrule prevents multiple copies made as it breaks the original selection set.
« Last Edit: August 28, 2011, 02:28:20 PM by SamR »

Jeff H

  • Needs a day job
  • Posts: 6150
Re: Cloned ObjectIDs
« Reply #5 on: August 29, 2011, 12:13:19 PM »
Could you just add a entry to each object's Extension dictionary as it is added, which could be used to filter for your entries and set TreatElementsAsHard  = false it will not be copied, and you tell from there what has and has not been copied.

SamR

  • Mosquito
  • Posts: 15
Re: Cloned ObjectIDs
« Reply #6 on: August 29, 2011, 02:02:31 PM »
I was worried that by adding the data to the entities I would need to search through every entity in the drawing for each operation and it would be slow and memory intensive.

But reading your reply .. I can create selection a filter based on xdata values without opening every xrecord?

It would sure make things a lot easier as then I won't need to collate move the handle entry keys from tree to tree  in the NOD if they are modified.

And how would xdata allow me to tell what is being copied? 
« Last Edit: August 29, 2011, 02:12:36 PM by SamR »

SamR

  • Mosquito
  • Posts: 15
Re: Cloned ObjectIDs
« Reply #7 on: August 30, 2011, 02:24:31 PM »
Adding xdata to each entity using "Appnames" to allow me to filter out entity groups is great. Saves a lot of messing around duplicating drawing data in the NOD. Not there yet but from what I've read it's what I should have done in the first place.

I'm still anticipating the same problem though with how I know what is being cloned. Will this help?