Author Topic: How do you organize your standard layers?  (Read 3421 times)

0 Members and 1 Guest are viewing this topic.

JCTER

  • Guest
How do you organize your standard layers?
« on: January 28, 2010, 04:46:27 PM »
Project:  My company wishes to standardize layers in AutoCAD.  We wish to develop a layer guideline, similar to the AIA Layering Standards, and make it easy for our users to stick to it.  During discussion with the bosses and I, an idea was developed to duplicate the "Linetype Manager" but to show a list of lines you can pick from, and hit a button that would create all the selected layers into your drawing.  The goal is to create a dialog that mimics the Linetype Manager, but has a list of layers, listing their Name, Color, Linetype properties, and allows a user to select/highlight multiple layers, and hit a "CREATE" button that will then create all the layers inside the current drawing.  I figure that for 95% of our layers, I can have them on a list, and there would be a rare case where someone has to create a new layer for a very job-specific situation.

My thought it to mimic the linetype manager almost directly.  I figure that I would create a text file with a layer definition on each line.  The dialog would read the contents of this file automatically, spit out the content in the form shown on the dialog, all in a manner which allows a user to pick from that list.  Then the button fires a loop that'll initiate the layer creation command for each layer definition.

That's my thought anyways, for how to skin this cat.

Am I going about this properly?  Should this be reasonably feasible?  Is there a better way to skin this cat?

I've seen many routines on the swamp in various languages that allow a user to do this... do you have an external file with layers defined, for easy updating/maintanence/revision, or is it hardcoded into your routines, and you just take it upon yourself to edit the routine/program every time you have to add a layer?

JCTER

  • Guest
Re: How do you organize your standard layers?
« Reply #1 on: January 28, 2010, 04:54:35 PM »
Bookmarked for later, http://msdn.microsoft.com/en-us/library/aa287535(VS.71).aspx has the beginnings of reading a text file with visual C#, though I'll have a bit of work figuring out the best way to have it 'know' how to read it, where to start reading, where to stop reading, etc, so that it can pass certain text strings to the variables in the C# code.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: How do you organize your standard layers?
« Reply #2 on: January 28, 2010, 06:25:42 PM »

Can you work out how to read a .CSV file ?
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.

JCTER

  • Guest
Re: How do you organize your standard layers?
« Reply #3 on: January 28, 2010, 06:33:47 PM »

Can you work out how to read a .CSV file ?


I have not yet learned how to do so in C# but have used, and somewhat understood, code that does so in LISP.

If a .CSV file is the way to go, efficiently, then I'm fine with that.  If reading an XML file is easier/preferable then I try that.  I just don't want to be stuck thinking inside an old box, with a new language, and thought I'd open our idea up to some comments from the more experienced gallery.


T.Willey

  • Needs a day job
  • Posts: 5251
Re: How do you organize your standard layers?
« Reply #4 on: January 28, 2010, 06:44:34 PM »
We have standard drawings with layer definitions with them.  I grab those, put up a dialog box, select the ones I want ( or a button to do all ), and just copy the layers over.  That way you can just copy over the linetypes also.  Other wise you have to the load the linetypes also, or you will error when assigning a linetype to the layer.  Just another idea.  But if you want to ability to edit the layers outside of Acad, then some more of database would be better.
Tim

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

Please think about donating if this post helped you.

JCTER

  • Guest
Re: How do you organize your standard layers?
« Reply #5 on: January 28, 2010, 06:54:50 PM »
I figured I would have to add some error trapping to detect if the selected linetype is loaded already, or another precaution to prevent that error, such as loading all our standard linetypes, then purging out the ones not used.

Maybe copying the layers from a separate .dwg file would be best.  I might look into that and see how to code that up.  Can only help to learn another method.  Thanks for the idea. 

I can see the benefit from learning to read txt, csv, or xml files, so maybe I'll still tool around with those as well.  I've become pretty eager and excited, the more I delve into this.  I almost feel powerful behind the desk, now  :-D

T.Willey

  • Needs a day job
  • Posts: 5251
Re: How do you organize your standard layers?
« Reply #6 on: January 28, 2010, 07:21:58 PM »
There are plenty of examples for reading text files here.  Look in the ' General Programming ' section for the word ' challenge '.  A lot of different ways to skin a cat, and a lot of good conversations along the way.
Tim

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

Please think about donating if this post helped you.

David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4075
Re: How do you organize your standard layers?
« Reply #7 on: January 29, 2010, 08:17:47 AM »
I use XML, and a really great example provided by Kerry in C#.
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)

DaveWish

  • Guest
Re: How do you organize your standard layers?
« Reply #8 on: January 29, 2010, 01:58:09 PM »
I need some csv code too. I am going to poke around soon and see if I find something or write my own in Boo. I'll post back if I do. I have a bunch of legacy stuff to support and work with right now to get some code out.

TimSpangler

  • Water Moccasin
  • Posts: 2010
  • CAD Naked!!
Re: How do you organize your standard layers?
« Reply #9 on: January 29, 2010, 02:26:23 PM »
Maybe something like this?

LayerCreator
ACA 2015 - Windows 7 Pro
All Comments and Content by TimSpangler, Copyright © 2016

JCTER

  • Guest
Re: How do you organize your standard layers?
« Reply #10 on: February 03, 2010, 04:40:09 PM »
It's not how I will eventually make the interface... I just have some buttons as placeholders to do what I want, step at a time, to check it out.

But... I'm very happy right now.  I made a text file with some stuff in it... I made a button to read that text file, line at a time, and put the text into a list box, line at a time... I'm... I'm getting closer.

I feel pretty.  Oh so pretty.

JCTER

  • Guest
Re: How do you organize your standard layers?
« Reply #11 on: February 03, 2010, 04:41:23 PM »
Step at a time... step at a time...

Next is turning those listbox entries into something selectable, and finding a way to collect all the strings of the selected items, and transfer them to a method that creates the layers.  Fun fun fun! (not sarcasm!)

Edit To Add:  And I actually know what all this gobblydo-gunk I'm writing means!

MickD

  • King Gator
  • Posts: 3637
  • (x-in)->[process]->(y-out) ... simples!
Re: How do you organize your standard layers?
« Reply #12 on: February 03, 2010, 05:12:35 PM »
Here's a short article on csv and looking at the FileHelpers metioned looked pretty good, I will be having a closer look at this myself pretty soon.

http://www.secretgeek.net/csv_trouble.asp

http://www.filehelpers.com/

mind you, if you are pretty confident on your csv source file, doing a 'split' or similar on the line string would be simple enough.
"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

JCTER

  • Guest
Re: How do you organize your standard layers?
« Reply #13 on: February 03, 2010, 05:17:24 PM »
mind you, if you are pretty confident on your csv source file, doing a 'split' or similar on the line string would be simple enough.
That's exactly what I'm doing.  Since I have 100% control over the .csv file, from the point of creation, I figured I'd keep it simple.  I had just read on splitting strings before I hopped back here and saw your post.

Thanks for the link.  I will check that out now.

dgorsman

  • Water Moccasin
  • Posts: 2437
Re: How do you organize your standard layers?
« Reply #14 on: February 03, 2010, 05:40:27 PM »
I strongly suggest XML, for a couple of reasons. 

The first, its a little easier (to me, at least) to keep things straight as compared to CSV.  Even if you only use the Windows XML to view it you can collapse nodes as needed to hide what you aren't looking for.

The second is its easier to programatically parse out what you want; not just a single line but character matching, nth selections, parent object of a match, and others.  Look into using XPath for search expressions.

Third (this is strictly icing) you can get into XSD schemas, which will help you when building the data files by limiting what you can put in.  It can also be used programmatically to check the format and contents before the file is loaded.

Fourth (more icing here), you can specify an XSL stylesheet to show the file contents as formatted HTML (including CSS and javascript for extra muscle) for pretty viewing outside of AutoCAD - the data file becomes the documentation.
If you are going to fly by the seat of your pants, expect friction burns.

try {GreatPower;}
   catch (notResponsible)
      {NextTime(PlanAhead);}
   finally
      {MasterBasics;}