PDA

View Full Version : Map 2007 - Save Back with VB.NET



plsmith.161671
2008-02-28, 10:31 PM
Trying to impliment a "save back" to attached drawings in the VB.NET API.

From what little documentation is available the procedure should be:

Foreach dwg in attacheddrawings...

dwg.LockForWrite(false)
dwg.CloneBack()
dwg.Save
dwg.UnlockForWrite()


When we do this we get an MapException error on the CloneBack method call. We tried this with CloneBackArea and get the same error.

We contacted Autodesk ADN tech support and they admit there is a problem with CloneBackArea but that CloneBack is working fine. But we have yet to have CloneBack or CloneBackArea work at all.

In the past in AutoLISP we used ade_saveobjs call to save queried/modified object back to the dwgs and also newly created objects by area. We are trying to replace all AutoLISP code with VB.NET to move forward to future versions of AutoCAD Map.

Thanks,

Paul L. Smith

plsmith.161671
2008-03-03, 03:52 PM
OK, after doing more trial and error, (lots of errors) it turns out hat CloneBack will generate a MapException error if that drawing the CloneBack method is being used on does NOT contain any entities to be written back to the attached drawing. By using GetNumInSaveSet method to return the number of modified or erased entities that are in the attached drawing and only calling CloneBack when the count is > 0.

The correct sequence for saving back to the attached drawings is slightly different than what was shown in my prior post above.

for each drawing in the drawing set...
1. use the method "GetNumInSaveSet" to determine if there are entities that are in the saveset and in the drawing. If there are then:
2. call AttachedDrawing.Lock(false) to lock the drawing file.
3. call AttachedDrawing.CloneBack to "write" the changes to the attached drawing.
4. call AttachedDrawing.Save to commit the changes to the attached drawing.
5. Call AttachedDrawing.Unlock to unlock the drawing file.

Autodesk is currently researching a "work-around" for the clonebackarea method for newly created entities that would fall with in the drawing's save back area extents.