Author Topic: Layout creation tool  (Read 16653 times)

0 Members and 1 Guest are viewing this topic.

Glenn R

  • Guest
Re: Layout creation tool
« Reply #15 on: August 22, 2008, 04:52:17 PM »
Damn! Run, right now, to any lisp startup script you have and add this:

Code: [Select]
(setvar "LAYOUTREGENCTL" 0)

In friends' experiments and mine own, very roughly, 20mb of RAM is used to cache each layout when the above variable is set to 2...start multiplying that by your figures above and I'm not surprised it was slow.

vegbruiser

  • Guest
Re: Layout creation tool
« Reply #16 on: August 22, 2008, 04:56:44 PM »
Cheers Glenn, I'll try that out. :)

EDIT: One problem down, Now I just have to figure out the best way to store the layer properties...?

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Layout creation tool
« Reply #17 on: August 22, 2008, 06:21:38 PM »
EDIT: One problem down, Now I just have to figure out the best way to store the layer properties...?

Maybe a dictionary.  You can store it by the layer name, and then have a list of all the properties.  Since you are the one putting in the information, then you will know what to do with it, since you would have to put it in as an object because it will be different types; strings ints ... etc.
Tim

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

Please think about donating if this post helped you.

vegbruiser

  • Guest
Re: Layout creation tool
« Reply #18 on: August 26, 2008, 06:26:45 AM »
EDIT: One problem down, Now I just have to figure out the best way to store the layer properties...?

Maybe a dictionary.  You can store it by the layer name, and then have a list of all the properties.  Since you are the one putting in the information, then you will know what to do with it, since you would have to put it in as an object because it will be different types; strings ints ... etc.
Thanks Tim, did you mean a DbDictionary (Autocad-specific) or the more generic System.Collections.Generic.Dictionary type?


Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Layout creation tool
« Reply #19 on: August 26, 2008, 06:28:31 AM »
He would have meant DbDictionary.
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.

Glenn R

  • Guest
Re: Layout creation tool
« Reply #20 on: August 26, 2008, 06:35:05 AM »
Kerry, I would have thought Dictionary<> myself, but I could be wrong.

Personally, I'd be saving and restoring a LayerState :)

vegbruiser

  • Guest
Re: Layout creation tool
« Reply #21 on: August 26, 2008, 07:28:16 AM »
Kerry, I would have thought Dictionary<> myself, but I could be wrong.

Personally, I'd be saving and restoring a LayerState :)
Thanks Glenn, I think I'll go with your suggestion - I don't want to reinvent the wheel after all.

:)

vegbruiser

  • Guest
Re: Layout creation tool
« Reply #22 on: August 26, 2008, 08:12:30 AM »
Kerry, I would have thought Dictionary<> myself, but I could be wrong.

Personally, I'd be saving and restoring a LayerState :)
I was about to ask for help in figuring out what the deal was with LayerStates, but after a bit of searching the Autodesk forums I came up with the following: -

(At the moment the two commands are called by the "savelayers" and "restorelayers" commands respectively.)

Code: [Select]
public class LayerCommands
   {
       [CommandMethod ("SaveLayers")]
       public static void SaveLayerstate()
       {
           Document doc = AcadApp.DocumentManager.MdiActiveDocument;
           Editor ed = doc.Editor;
           DocumentLock doclock = doc.LockDocument();
           Database db = doc.Database;
           LayerStateManager lsm = db.LayerStateManager;
           string dwgname = "test";
           lsm.SaveLayerState(dwgname, LayerStateMasks.Frozen |
LayerStateMasks.Locked | LayerStateMasks.On, ObjectId.Null);
       }
       [CommandMethod("RestoreLayers")]
       public static void RestoreLayerstate()
       {
           Document doc = AcadApp.DocumentManager.MdiActiveDocument;
           Editor ed = doc.Editor;
           DocumentLock doclock = doc.LockDocument();
           Database db = doc.Database;
           LayerStateManager lsm = db.LayerStateManager;
           string dwgname = "test";
           lsm.RestoreLayerState(dwgname, ObjectId.Null, 0,
LayerStateMasks.Frozen | LayerStateMasks.Locked | LayerStateMasks.On);
       }
   }
For once that was quite easy.  :lol:

You can test that this works by running first the savelayers command in a drawing with a few layers. Then change some of the properties of those layers, and run the restorelayers command. You should then see that the properties you changed have been restored.

For my purposes (I think) I'm only storing the Frozen, Locked and On settings, but you can add more as you see fit.

Glenn R

  • Guest
Re: Layout creation tool
« Reply #23 on: August 26, 2008, 08:16:09 AM »
I was waiting for the questions to start popping about LayerStates ;)

Why are you locking the document btw?

vegbruiser

  • Guest
Re: Layout creation tool
« Reply #24 on: August 26, 2008, 08:19:19 AM »
I was waiting for the questions to start popping about LayerStates ;)

Why are you locking the document btw?
Ah, that's because of the ol' "Copy+Paste" chestnut. My bad.

Glenn R

  • Guest
Re: Layout creation tool
« Reply #25 on: August 26, 2008, 08:19:53 AM »
Also, if you are going to lock the document, make sure you unlock it when you're finished or nasty things can happen. One way to do this is to wrap it in a 'using' block.

Glenn R

  • Guest
Re: Layout creation tool
« Reply #26 on: August 26, 2008, 08:20:48 AM »
I was waiting for the questions to start popping about LayerStates ;)

Why are you locking the document btw?
Ah, that's because of the ol' "Copy+Paste" chestnut. My bad.

Ah...no worries then.

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Layout creation tool
« Reply #27 on: August 26, 2008, 11:11:52 AM »
EDIT: One problem down, Now I just have to figure out the best way to store the layer properties...?

Maybe a dictionary.  You can store it by the layer name, and then have a list of all the properties.  Since you are the one putting in the information, then you will know what to do with it, since you would have to put it in as an object because it will be different types; strings ints ... etc.
Thanks Tim, did you mean a DbDictionary (Autocad-specific) or the more generic System.Collections.Generic.Dictionary type?

Just to sum it up; I did mean the system Dictionary class.  Not like it matters now, as you have found a way that works.
Tim

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

Please think about donating if this post helped you.

Glenn R

  • Guest
Re: Layout creation tool
« Reply #28 on: August 27, 2008, 12:44:51 PM »
Speaking of LayerStates, have you seen Xref States?

vegbruiser

  • Guest
Re: Layout creation tool
« Reply #29 on: August 27, 2008, 02:46:59 PM »
Interesting, I shall look at that in more detail tomorrow (when I'm being paid to do so) :)