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

Copy entity - new ObjectId / Handle?

7 REPLIES 7
Reply
Message 1 of 8
mabe2k11
1082 Views, 7 Replies

Copy entity - new ObjectId / Handle?

Hello!

I have a problem with ObjectIDs / handles.
In my drawing I have a dynamic block and a text which shows the attributes of that. To keep it up-to-date I added XDATA to the text, with the handle of the block. So I can update the text sometimes.
But when I copy (ACAD copy) both, the block and the text, I get a very big problem. The handle at the XDATA of the text is the same like before. But it should be the handle of the copy.
Is it possible to manage this?
Perhaps I can add an event-listener. But how do I get the oldID and the copyID of the block.

Thank you.
7 REPLIES 7
Message 2 of 8
Anonymous
in reply to: mabe2k11

I think this can be done with help of reactor: AcDbObjectReactor::copied(const AcDbObject* oldObj,const AcDbObject* newObj);
Message 3 of 8
mabe2k11
in reply to: mabe2k11

Is there a dotnet-EventHandler for AcDbObjectReactor::copied(...)?
Message 4 of 8
Anonymous
in reply to: mabe2k11

Oops. IMHO, answer is NO - because ObjectARX .NET can not produce custom object... 😞 You must do it with help of native ObjectARX.
Message 5 of 8
simonkx
in reply to: mabe2k11

Hi,
I want to know how to copy an entity with C#,and can you show me some examples?
Thanks
Message 6 of 8
mabe2k11
in reply to: mabe2k11

Hi!

The copy-method, I mean is the one of AutoCAD (the user make the copy). I've never done this in .net before. But you can drive the
COPY command via the command line (http://discussion.autodesk.com/thread.jspa?threadID=467227).

But back to my question. Is it possible to make a connection between two entities in .net? I'm going forward do this with groups (both objects are in a group, and when i change one, I look in the group for the other object to change it too). But I think it's not the best solution.
Message 7 of 8
Anonymous
in reply to: mabe2k11

I've thought about this a bunch in the past, because to make a callout whose text is, say, a northing or easting,
representing the end of the leader, you have to make the text "aware" of the leader. Same goes when labeling stations
and offsets of a home brew road alignment. The leader is not just one segement, but can be a bunch, meaning the text
can move in relation to teh leader "end".

Groups are pretty handy for this, but if you wblock stuff around, the groups get lost. We wblock stuff around like
balls in a clown's hands so that is an obstacle.
The thing about groups is they are automatically maintained when you do a copy command.
I thought about using xdata to teach the leader and text about eachother so they could "heal" themselves if confused.

I never came to a good answer though because you don't want a command reactor involved, anyone can mess that up by using
a session without "my tools". The mapcad folks did the leader callout thing using a custom object. But I hate custom
objects. I want a tool that can hook text and leader from any text and pline. I would still need a prog to do
something with that, like update a station or offset, but thats ok. Its just keeping the text and leaders in order
thats tricky.

I'd sure like to know if a persistent reactor could be done for the text and leader, so they know to modify themselves
when copied. Not sure how persistent reactors get propogated though, and how stable that would be.

mabe2k <>
|>Hi!
|>
|>The copy-method, I mean is the one of AutoCAD (the user make the copy). I've never done this in .net before. But you can drive the
|>COPY command via the command line (http://discussion.autodesk.com/thread.jspa?threadID=467227).
|>
|>But back to my question. Is it possible to make a connection between two entities in .net? I'm going forward do this with groups (both objects are in a group, and when i change one, I look in the group for the other object to change it too). But I think i
|>t's not the best solution.
James Maeding
Civil Engineer and Programmer
jmaeding - athunsaker - com
Message 8 of 8
mabe2k11
in reply to: mabe2k11

Hi!

I did it with groups and I thought it woks quite good. But then I have seen your reply. I have never copied the group (copy/paste or with wblock) into a new drawing. Now I see the disaster. The groups get really lost!
I thought I can build a new copy command, but it's difficult to tell the draftsmen to use this instead of the normal command if they copy something with my groups.
So I agree that a quite good solution could be adding xdata to each object for selfhealing. But then I have to use event handlers to do this after inserting objects. But what's with the windows "copy/paste"?
I'm not glad about this - the source code gets more and more complex and the performance is not the best with all these event handlers.

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