Copy/Paste on custom entity

Copy/Paste on custom entity

alex_b
Advocate Advocate
1,442 Views
24 Replies
Message 1 of 25

Copy/Paste on custom entity

alex_b
Advocate
Advocate
Hi
class XEl public AcDbEntity {
.....
AcGePoint3d ;
AcDbHandle;//handle to another custom entity (another class)
......
}

Now, when we perform a Copy/Paste sequence to another drawing, the XEl::worldDraw() is called, it tries to open the entity pointed to by the member handle and of course errors out.
The curious part is that the error is Acad::eWasErased when in fact the entity is nonexistent.
Any good explanation?
BTW, the solution would be the same (create a new entity and point the handle at it) but I'd like to know if there is a way do distinguish between an erased entity and a nonexistent one.

TIA

alex
0 Likes
1,443 Views
24 Replies
Replies (24)
Message 21 of 25

alex_b
Advocate
Advocate
Thanks for the advice.
I am using AcDbLayoutManager::getActiveLayoutBTRId() to open the current layout and append to it, as Art suggested, and it works OK.
About the handles vs. pointers: replaced all the handles with pointers - as per Art's and Owen's advice - and it works. I still do not understand why we got the wrong error code while using handles.

alex
0 Likes
Message 22 of 25

Anonymous
Not applicable
It's possible that that handle actually did exist in that drawing - for some
other object that was erased. Some processes create temp objects and then
erase them. It could have been the handle for such an object.

wrote in message news:5940477@discussion.autodesk.com...
Thanks for the advice.
I am using AcDbLayoutManager::getActiveLayoutBTRId() to open the current
layout and append to it, as Art suggested, and it works OK.
About the handles vs. pointers: replaced all the handles with pointers - as
per Art's and Owen's advice - and it works. I still do not understand why we
got the wrong error code while using handles.

alex
0 Likes
Message 23 of 25

alex_b
Advocate
Advocate
It was a new dwg, created with no template.
By "some processe" you mean internal, even in a newly created dwg?
Thanks

alex
0 Likes
Message 24 of 25

Anonymous
Not applicable
The paste operation itself might end up creating temp objects that get
erased. I don't know that that is what happened, but it is a possibility.

wrote in message news:5940670@discussion.autodesk.com...
It was a new dwg, created with no template.
By "some processe" you mean internal, even in a newly created dwg?
Thanks

alex
0 Likes
Message 25 of 25

alex_b
Advocate
Advocate
Art.
I see. Anyway, I'm glad I abandoned the handles.
Thank you

alex
0 Likes