Results 1 to 6 of 6

Thread: puzzled! eWasOpenForWrite error

  1. #1
    Member
    Join Date
    2012-09
    Posts
    2
    Login to Give a bone
    0

    Default puzzled! eWasOpenForWrite error

    hello,everybody!
    I get a error 'eWasOpenForWrite' in the code below, can anyone tell me how to tackle this problem?
    thanks.

    Code:
            private static void CheckInference(List<Solid3d> solids) {
                Database db = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Database;
                using (Transaction tran = db.TransactionManager.StartTransaction()) {
                    BlockTable blockTable = tran.GetObject(db.BlockTableId, OpenMode.ForRead) as BlockTable;
                    BlockTableRecord blockRecord = tran.GetObject(blockTable[BlockTableRecord.ModelSpace], OpenMode.ForWrite) as BlockTableRecord;
    
                    for (int i = 0; i < solids.Count - 1; i++) {
                        Solid3d solid1 = solids[i];
                        for (int j = i + 1; j < solids.Count; j++) {
                            Solid3d solid2 = solids[j];
                            if (solid1.Layer != solid2.Layer) {
                                if (solid1.CheckInterference(solid2)) {
                                    Solid3d copySolid1 = solid1.Clone() as Solid3d;
                                    copySolid1 .BooleanOperation(BooleanOperationType.BoolIntersect, solid2.Clone() as Solid3d);//------eWasOpenForWrite error occured here
                                    copySolid1 .ColorIndex = 1;
                                    blockRecord.AppendEntity(copySolid1 );
                                    tran.AddNewlyCreatedDBObject(copySolid1 , true);
                                    tran.Commit();
                                }
                            }
                        }
                    }
                }
            }
    Last edited by 289924688488291; 2012-09-11 at 07:39 AM.

  2. #2
    Administrator BlackBox's Avatar
    Join Date
    2009-11
    Posts
    5,672
    Login to Give a bone
    0

    Default Re: puzzled! eWasOpenForWrite error

    Welcome to AUGI!

    First, I do not understand why you choose to iterate a valid selection set based in the layers supplied, only to check for solids, when you could simply include the solid as part of your filter.

    Second, if I am understanding your code correctly, you recursively call CheckInterference() on an ObjectId that you've already opened using the Transaction, hence the eWasOpenForWrite error. Just a guess.

    HTH
    "How we think determines what we do, and what we do determines what we get."

    Sincpac C3D ~ Autodesk Exchange Apps

    Computer Specs:
    Dell Precision 3660, Core i9-12900K 5.2GHz, 64GB DDR5 RAM, PCIe 4.0 M.2 SSD (RAID 0), 16GB NVIDIA RTX A4000

  3. #3
    Member
    Join Date
    2012-09
    Posts
    2
    Login to Give a bone
    0

    Default Re: puzzled! eWasOpenForWrite error

    thanks , RenderMan.
    but if not call the function CheckInterference() recursively ,how can i get the Intersection of any two solids in the list?
    any idea?

  4. #4
    Administrator BlackBox's Avatar
    Join Date
    2009-11
    Posts
    5,672
    Login to Give a bone
    0

    Default Re: puzzled! eWasOpenForWrite error

    Quote Originally Posted by 289924688488291 View Post
    but if not call the function CheckInterference() recursively ,how can i get the Intersection of any two solids in the list?
    any idea?
    Actually, I am mistaken... I accidentally misread your CheckInference() Method, and thought you were calling it recursively (when in fact you're calling the CheckInterference() Method... Presumably, the solid2 Object being open for write, should not in fact be an issue.

    I've never actually needed to code something like this, so I'm not exactly sure what would be best here... This article, and the comments posted below it, may be of use.

    Hopefully someone more knowledgeable will be along shortly.
    "How we think determines what we do, and what we do determines what we get."

    Sincpac C3D ~ Autodesk Exchange Apps

    Computer Specs:
    Dell Precision 3660, Core i9-12900K 5.2GHz, 64GB DDR5 RAM, PCIe 4.0 M.2 SSD (RAID 0), 16GB NVIDIA RTX A4000

  5. #5
    Administrator BlackBox's Avatar
    Join Date
    2009-11
    Posts
    5,672
    Login to Give a bone
    0

    Default Re: puzzled! eWasOpenForWrite error

    Per the Edit 3D Solid (.NET) Reference... Consider replacing this line:

    Code:
                        if (solid1.CheckInterference(solid2))
    ... With this, and see if that helps:

    Code:
                        if (solid1.CheckInterference(solid2) == true)
    Unless I am overlooking something, this is the only real difference I see between the example found in the documentation, and your code.

    HTH
    "How we think determines what we do, and what we do determines what we get."

    Sincpac C3D ~ Autodesk Exchange Apps

    Computer Specs:
    Dell Precision 3660, Core i9-12900K 5.2GHz, 64GB DDR5 RAM, PCIe 4.0 M.2 SSD (RAID 0), 16GB NVIDIA RTX A4000

  6. #6
    Woo! Hoo! my 1st post
    Join Date
    2011-07
    Posts
    1
    Login to Give a bone
    0

    Default Re: puzzled! eWasOpenForWrite error

    If you clone an entity, you must AppendEntity to Block Table Record and AddNewlyCreatedDBOjbect to a Transaction and only then you can use them for other operations.

Similar Threads

  1. eWasOpenForWrite
    By cadprog in forum Dot Net API
    Replies: 3
    Last Post: 2012-04-10, 08:51 AM
  2. Replies: 7
    Last Post: 2009-05-26, 04:51 PM
  3. eWasOpenForWrite
    By cristiandabu in forum Dot Net API
    Replies: 1
    Last Post: 2009-01-21, 08:11 PM
  4. Puzzled roof (warpped)
    By david_peterson in forum ACA General
    Replies: 10
    Last Post: 2008-02-29, 01:12 PM
  5. Puzzled by mpedit?
    By ddempsie in forum AutoCAD General
    Replies: 2
    Last Post: 2007-11-12, 01:31 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •