Author Topic: eWasOpenForWrite  (Read 10254 times)

0 Members and 1 Guest are viewing this topic.

Glenn R

  • Guest
Re: eWasOpenForWrite
« Reply #15 on: April 08, 2008, 02:16:34 PM »
I just noticed this, we batch thru all our drawings and bind all xrefs before burning to dvd's.

Here is the method in C# which has worked for us:

Code: [Select]
static public void bindAllXrefs()
        {
            try
            {
                Document pCurDoc = AcadApp.DocumentManager.MdiActiveDocument;
                Database pCurDb = pCurDoc.Database;

                Editor pEd = pCurDoc.Editor;

                //**********
                Document curDoc = AcadApp.DocumentManager.MdiActiveDocument;
                curDoc.LockDocument();
                //**********

                XrefGraph pXrefGraph = pCurDb.GetHostDwgXrefGraph(true);
                if (pXrefGraph.IsEmpty || pXrefGraph.NumNodes == 1)
                {
                    pEd.WriteMessage("\nNo Xrefs found. ");
                    return;
                }
                using (Transaction pTr = pCurDoc.TransactionManager.StartTransaction())
                {
                    BlockTable pBlkTbl = (BlockTable)pTr.GetObject(pCurDb.BlockTableId, OpenMode.ForWrite);
                   
                    for (int i = 0; i < pXrefGraph.NumNodes; i++)
                    {
                        XrefGraphNode pXrefGraphNode = (XrefGraphNode)pXrefGraph.GetXrefNode(i);
                        if (pXrefGraphNode.NumIn == 0)
                            continue;
                        if (pXrefGraphNode.IsNested)
                            continue;
                        if (pXrefGraphNode.NumIn > 1)
                            continue;

                        pEd.WriteMessage("\nXrefname: " + pXrefGraphNode.Name);
                        pEd.WriteMessage("\nNested Status: " + pXrefGraphNode.IsNested.ToString());
                        pEd.WriteMessage("\nIncoming Nodes: " + pXrefGraphNode.NumIn.ToString());
                        pEd.WriteMessage("\nOutgoing Nodes: " + pXrefGraphNode.NumOut.ToString());

                        EFCO.Util.XrefLib.Wrapper.acedXrefBind(pXrefGraphNode.Name, true, true, pCurDb);
                    }
                    pTr.Commit();
                    pEd.WriteMessage("\nEFCO BIND PROCESS COMPLETE. ");
                }
            }
            catch { }
        }

I don't have time to parse your code but maybe something will stick out for you.

That code looks more than just familiar...

Draftek

  • Guest
Re: eWasOpenForWrite
« Reply #16 on: April 08, 2008, 03:54:25 PM »
Oh Really!

Fill me in.

visualassembly 'wrote' this for me a while back when he worked for me.

Glenn R

  • Guest
Re: eWasOpenForWrite
« Reply #17 on: April 08, 2008, 04:02:19 PM »
Linkage

Notice the variable naming convention I was using at the time (habbit from my C++ days), prefixing object variables with 'p' for 'pointer'...

visualassembly

  • Guest
Re: eWasOpenForWrite
« Reply #18 on: April 08, 2008, 04:36:13 PM »
That's where I got that from!   :roll:

Now where did I get the dll import from......  I think I swiped that part from Acad's own forums.

Thanks for the help Glenn.  Even if it is really late.  This was part of the very first ACAD app I got to write.  It was (and I'm assuming, still is) used for batching through our 28,000+ dwg library to bind the xrefs, zoom extents the dwg's, toggle layers off and on, batch plot jpg's (in two sizes), pdf's, and made coffee all the same time.   Ahhh... memories.


Draftek

  • Guest
Re: eWasOpenForWrite
« Reply #19 on: April 09, 2008, 08:03:16 AM »
well, I see I even posted in that thread. I probably even directed visualassembly here to check it out.

I typically will not copy code of any kind (stubborn that way).

I'll have the new guy add you to the comments.

Glenn - I wonder how much other stuff you have written for me - Thanks :)


cadpro

  • Guest
Re: eWasOpenForWrite
« Reply #20 on: April 10, 2008, 01:26:27 AM »
I do not have objectarx as I'm using VS Express 2008. So I got the arx function to work in .NET by reading Kean's website.

I get two of these for acedXrefBind. Which one would be correct to pick?

Dump of file acad.exe
        682  298 003FEFA0 ?acedXrefBind@@YA?AW4ErrorStatus@Acad@@PB_W_N1IPAVAcDbDatabase@@@Z
        683  299 003FF220 ?acedXrefBind@@YA?AW4ErrorStatus@Acad@@PB_W_N1PAVAcDbDatabase@@@Z

BTW, I have Autocad 2008.

Thanks

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: eWasOpenForWrite
« Reply #21 on: April 10, 2008, 04:32:19 AM »
        // For AutoCAD 2008, 2007:
    [DllImport("acad.exe", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode,
      EntryPoint = " ?acedXrefBind@@YA?AW4ErrorStatus@Acad@@PB_W_N1PAVAcDbDatabase@@@Z")]   
    extern public static ErrorStatus acedXrefBind17(string XrefBlockname, bool bInsertBind, bool bQuiet, IntPtr db);
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

cadpro

  • Guest
Re: eWasOpenForWrite
« Reply #22 on: April 10, 2008, 07:37:21 AM »
Thanks Kerry. I got it to work.

After some digging and researching with different method of coding, I understand that after I run the scalelistedit command to reset the list, if there are any xxx_XREF scales from one particular dwg, ONLY that dwg won't bind with the code. This means that AutoCAD does not close the xref dwg database after it resets the scales. Correct me if I'm wrong.

Thanks 

cadpro

  • Guest
Re: eWasOpenForWrite
« Reply #23 on: April 10, 2008, 07:55:31 AM »
Oh! One more discovery! It doesn't even bind manually after resetting scalelist.  :-o

MickD

  • King Gator
  • Posts: 3653
  • (x-in)->[process]->(y-out) ... simples!
Re: eWasOpenForWrite
« Reply #24 on: November 02, 2009, 05:30:33 PM »
Anyone found a solution to the original problem yet?

I've only had it happen with 3d solids and it's because of the 'solidhist' variable that records any modifications and stores them for backtracking, this only came in in 2008/9 I think.

The way I get around it is to set SOLIDHIST to 0 (off) and run the BREP command selecting all which clears any history, once this is done the drg behaves as normal.

If you rely on the solid's history then you may need to check 'isOpenForWrite' and do some mojo to get around it.
"Programming is really just the mundane aspect of expressing a solution to a problem."
- John Carmack

"Short cuts make long delays,' argued Pippin.”
- J.R.R. Tolkien