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

wblock method isfailing

2 REPLIES 2
Reply
Message 1 of 3
Anonymous
624 Views, 2 Replies

wblock method isfailing

Hi,

 

I am facing problem with wblock method call.

We have created custom objects, derived from “AcDbCurve” and overridden “wblockCloneStd” for our custom entities.

There, at the end of “wblockCloneStd”, we call “AcDbCurve::subWblockClone”. But sometimes it returns “ewasErased”.  Our code does not set “ewasErased” status for custom entity, neither “subErase” of that custom object is executed.

But wblock call fails with return status “eInvalidKey” when “AcDbCurve::subWblockClone” returns “ewasErased”.

 

Our complete work flow is, as follows -:

Through our AutoCAD based software, user adds source drawings (not as xRefs) to main drawings.

Here code creates block containing all entities from source drawing and add that block to the main drawing. So if there are 2 source drawings then 2 blocks will be added to main drawing.

When user makes visible any particular drawing, then block is exploded and entities are added to the main drawing and made visible.

 

Later user selects option Publish.

In publish, we creates new drawing for each source drawing.

Here the entities from main drawing are added to the new drawing using wblock command.

Here wblock is failing for some entities.

 

Some other scenario where source drawing entities are not made visible (i.e. block creation & explode part does not executed in this case) then entities from source drawings are copied successfully to the new drawings, without any issue.

 

Another case, when source drawing entities are made visible in main drawing and then if main drawing is saved (File -> save option) before publish, then wblock is working fine for all entities. Our overridden method “wblockCloneStd” does not return status as “ewasErased” for any entity, in this case.

 

So I think problem is with making visible source drawing entities in main drawing and using unsaved main drawing in publish.

 

But I need to figure out what exactly should be done so that wblock will be successful always (irrespective of making visible source drawing entities in main drawing / saving main drawing)

 

Please help me in finding out why I am getting eWasErased from  “AcDbCurve::subWblockClone” and how can I avoid that so that wblock command will work fine for all our custom objects.

 

 Thanks and regards

 ND.

2 REPLIES 2
Message 2 of 3
fenton.webb
in reply to: Anonymous

Sorry, but it's impossible for me to imagine what the problem might be. I bet it's something to do with an ObjectID being null somewhere or maybe your custom entity doesn't forward the base dwgin/out in your own implementation of dwgIn and Out, but it's just guessing.

 

Can you post a sample project on here that we can take a look at please?




Fenton Webb
AutoCAD Engineering
Autodesk

Message 3 of 3
Anonymous
in reply to: fenton.webb

hi,

 

Thanks a lot for your reply...  I will check dwgin/ out methods for our custome entities.

While searching on internet found "AutoCAD DevBlog" and there found one article by "Xiaodong Liang".

 Its link is as follows -:

 

http://adndevblog.typepad.com/autocad/2013/03/acdbepermanentlyerased-when-open-cloned-object-during-...

 

As per that article -: 

While doing wblock on entire database, AutoCAD does a fast wblock operation, which means that AutoCAD does not really clone the objects but simulates doing it because the goal is to save the 'clones' to a file. In order to prevent other users from modifying the clone objects (since the clone and original object are the same object in memory),

AutoCAD returns "ePermanentlyErased" error code when an application tries to open and modify a clone.

 

In our context, we first make deep clone of entities / objects from source drawing into current project drawing (while making block) and then invoke wblock.

I think it is similar to the scenario mentioned in the article.

In their case "ePermanentlyErased" error code is returned while in our case "ewasErased" is returned.

 

2 solutions are mentioned in the article -:

1)  Open the original object instead of the clone, and to read information from it. But if you want to modify the object, be aware that both the original and the clone will be affected.

This approach will be more complicated because in our software we allow user to change the source drawing objects in main drawing .

 

2) Use AcDbDatabase::forceWblockDatabaseCopy(). Doing this will force AutoCAD to create real clones of the objects.  As per ObjectARX help we need to call this method from within the AcRxEventReactor::wblockNotice() or AcEditorReactor::wblockNotice(). I tried with this but my problem is not resolved yet.

 

About making sample project - I will try... but not sure whether problem will be reproducible in that. 

Thanks once again for your time & hope that above mentioned article could help us to understand the problem..

 

Thanks and regards

ND.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost