Author Topic: Prevent Block Explode  (Read 10087 times)

0 Members and 1 Guest are viewing this topic.

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Prevent Block Explode
« Reply #15 on: January 18, 2011, 12:22:42 PM »
Add the line ' (vl-load-com) ' as the first line under the defun.  That will load the ActiveX Arx, so that lisp can interact with ActiveX ( no matter how many times you call it, the arx will only be loaded once ).  Sorry about that.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

ronjonp

  • Needs a day job
  • Posts: 7529
Re: Prevent Block Explode
« Reply #16 on: January 18, 2011, 12:24:33 PM »
Add (vl-load-com).

** Too slow :lol:

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

vegbruiser

  • Guest
Re: Prevent Block Explode
« Reply #17 on: January 18, 2011, 12:29:58 PM »
Add the line ' (vl-load-com) ' as the first line under the defun.  That will load the ActiveX Arx, so that lisp can interact with ActiveX ( no matter how many times you call it, the arx will only be loaded once ).  Sorry about that.
Thanks Tim, that does the trick. :)

Jeff H

  • Needs a day job
  • Posts: 6150
Re: Prevent Block Explode
« Reply #18 on: January 18, 2011, 10:39:50 PM »
that works for the blocks IN the drawing, but what about the drawing itself?  meaning, the file that gets inserted as a block needs the property set

I tried it on drawing inserted and it worked.

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Prevent Block Explode
« Reply #19 on: January 19, 2011, 12:04:02 PM »
that works for the blocks IN the drawing, but what about the drawing itself?  meaning, the file that gets inserted as a block needs the property set

I tried it on drawing inserted and it worked.


What he is talking about, is setting a drawing explode'ability, so that when it is inserted, the block that represents the drawing is/isn't explodable.  To do that, you have to change the explodable property of the model space's block table record of the drawing in question.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

Jeff H

  • Needs a day job
  • Posts: 6150
Re: Prevent Block Explode
« Reply #20 on: January 21, 2011, 07:03:53 AM »
what about setting the currentDrawing to explodable?  I have hundreds of blocks I just inherited that need that property changed

I think I understand you will have to do like the previous code if file is already inserted in a drawing


Code: [Select]
    [CommandMethod("ChangeCurrentDrawingExplodableProperty")]
        public void ChangeCurrentDrawingExplodableProperty()
        {
            Document doc = Application.DocumentManager.MdiActiveDocument;
            Database db = doc.Database;
           
            using (Transaction trx = db.TransactionManager.StartTransaction())
            {
                BlockTableRecord msBtr = SymbolUtilityServices.GetBlockModelSpaceId(db).GetObject(OpenMode.ForWrite) as BlockTableRecord;
                msBtr.Explodable = !msBtr.Explodable;
                trx.Commit();
               

            }

            doc.SendStringToExecute("QSAVE ", true, false, false);
        }


David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4075
Re: Prevent Block Explode
« Reply #21 on: January 21, 2011, 08:51:57 AM »
This is what i ended up doing
Code: [Select]
[CommandMethod("CEP")]
        public static void ChangeExplodableProperty()
        {
            Document doc = Application.DocumentManager.MdiActiveDocument;
            Database db = doc.Database;
            Editor ed = doc.Editor;

            using (Transaction trx = db.TransactionManager.StartTransaction())
            {

                BlockTable bt = db.BlockTableId.GetObject(OpenMode.ForRead) as BlockTable;
                foreach (ObjectId objId in bt)
                {
                    BlockTableRecord btr = (BlockTableRecord)objId.GetObject(OpenMode.ForRead);

                    if (btr.Name == "*Model_Space")
                    {
                        ed.WriteMessage("\n" + btr.Name + " Explodable property is set to " + btr.Explodable.ToString());
                        btr.UpgradeOpen();
                        btr.Explodable = !btr.Explodable;
                        ed.WriteMessage("\n" + btr.Name + " Explodable property has changed to " + btr.Explodable.ToString());
                    }
                }


                trx.Commit();
            }
        }

I left the extra messages in the code from above so I could see it from the command line.  I wrote a script that processed the files.  It took about 5 minutes to process the files.
Everyone has a photographic memory, Some just don't have film.
They say money can't buy happiness, but it can buy Bacon and that's a close second.
Sometimes the question is more important than the answer. (Thanks Kerry for reminding me)