Author Topic: Layer Creator Project  (Read 38957 times)

0 Members and 1 Guest are viewing this topic.

GDF

  • Water Moccasin
  • Posts: 2081
Re: Layer Creator Project
« Reply #15 on: July 02, 2008, 02:51:18 PM »
i store all predefined layers in a dwg template, and just use dbx to import.
good thing is that layers' linetypes are imported automaticaly.
Code: [Select]
(defun ImportAllSmth

       (Smth DwgName / dbxDocObj dbxSmthObj AcadObj AcDocObj SmthCollectObj)
  (and (setq DwgName (findfile DwgName))
       (setq AcadObj (vlax-get-acad-object))
       (setq AcDocObj (vla-get-ActiveDocument AcadObj))
       (not (vl-catch-all-error-p
      (setq SmthCollectObj (vl-catch-all-apply 'vlax-get-property (list AcDocObj Smth)))
    )
       )
       (not (vl-catch-all-error-p
      (setq dbxDocObj
     (vl-catch-all-apply
       'vla-GetInterfaceObject
       (list
AcadObj
(strcat "ObjectDBX.AxDbDocument." (substr (getvar "ACADVER") 1 2))
       )
     )
      )
    )
       )
       (not (vl-catch-all-error-p
      (vl-catch-all-apply 'vla-open (list dbxDocObj DwgName))
    )
       )
       (not (vl-catch-all-error-p
      (setq dbxSmthObj (vl-catch-all-apply 'vlax-get-property (list dbxDocObj Smth)))
    )
       )
       (vlax-for LayerObj dbxSmthObj
(vl-catch-all-apply
   'vla-CopyObjects
   (list dbxDocObj
(vlax-safearray-fill
   (vlax-make-safearray vlax-vbObject (cons 0 0))
   (list LayerObj)
)
SmthCollectObj
   )
)
       )
       (not (vla-Regen AcDocObj acActiveViewport))
  )
  (mapcar (function
    (lambda (Obj)
      (and Obj (not (vl-catch-all-error-p Obj)) (vlax-release-object Obj))
    )
  )
  (list dbxSmthObj dbxDocObj SmthCollectObj AcDocObj AcadObj)
  )
)
;;;(ImportAllSmth "Layers" "vk_Standard.dwg")

This is pretty slick, me likes. You could use this as a good starting point (like a template file) or to import into an existing drawing.

Gary
Why is there never enough time to do it right, but always enough time to do it over?
BricsCAD 2020x64 Windows 10x64

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Layer Creator Project
« Reply #16 on: July 02, 2008, 02:52:23 PM »
Yes, good work VovKa.
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

GDF

  • Water Moccasin
  • Posts: 2081
Re: Layer Creator Project
« Reply #17 on: July 02, 2008, 02:57:37 PM »
Alan

*/ ; name      PlotStyleName color   LineType   Freeze   Lock    LayerOn
*+ Default Data    ;  Light   ;7  ; Continuous; thawed; Unlocked; on
FJ1_A-DIMS         ;  ; ; ; ; ;


I would add plot and noplot to the data. This data is stored in an ini file similar to your routine.


Gary
You missed one of the concepts of the routine.

YOU the creator of the Data File determine the data.
You start with the layer name & then add the properties you want in the data file.
You also determine the order of the data, although logic would say put the name as the
first column and then it's up to you what comes next & what you want to include or exclude
from the data file.


Alan

I think we are on the same page. Here is how I placed it within a dialog box. The first column is for plot noplot the "x". The list within the dailpg box is created by reading an ini file.

Gary
Why is there never enough time to do it right, but always enough time to do it over?
BricsCAD 2020x64 Windows 10x64

JohnK

  • Administrator
  • Seagull
  • Posts: 10604
Re: Layer Creator Project
« Reply #18 on: July 02, 2008, 03:02:46 PM »
Holly complicated batman!
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

TimSpangler

  • Water Moccasin
  • Posts: 2010
  • CAD Naked!!
Re: Layer Creator Project
« Reply #19 on: July 02, 2008, 03:36:17 PM »
James touches on a great point about ObjectDBX but the thing about it I didn't like was separation of layers into differant disciplines or differant contractors layers, etc..  That is the reason that I went with the external file(s).  And I tried to keep things simple, however the more people use it the more emails I get about wanting new features.  :ugly:

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

VovKa

  • Water Moccasin
  • Posts: 1626
  • Ukraine
Re: Layer Creator Project
« Reply #20 on: July 02, 2008, 03:41:02 PM »
Yes, good work VovKa.
thanx Alan.
as to your project, i think the easiest way to read your data file is to make it compatible with read function
something like
Code: [Select]
(setq LayData (read (strcat "(" (read-line DataFile) ")")))
and remember, one day people will demand support for RGB layer colors :)

JohnK

  • Administrator
  • Seagull
  • Posts: 10604
Re: Layer Creator Project
« Reply #21 on: July 02, 2008, 03:50:42 PM »
DBX? If your going to store your layers in a dwg then why not just insert the dwg as a block?
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Layer Creator Project
« Reply #22 on: July 02, 2008, 03:56:59 PM »
DBX? If your going to store your layers in a dwg then why not just insert the dwg as a block?
Won't correct layers.  I have a routine that will correct the layers to meet company standards if the don't.  You have to use code to do it, and I use ODBX.
Tim

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

Please think about donating if this post helped you.

TimSpangler

  • Water Moccasin
  • Posts: 2010
  • CAD Naked!!
Re: Layer Creator Project
« Reply #23 on: July 02, 2008, 03:57:21 PM »
That's what we do here (were I work) when we clean a dwg (purge, audit, insert the std dwg, save, close)
ACA 2015 - Windows 7 Pro
All Comments and Content by TimSpangler, Copyright © 2016

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Layer Creator Project
« Reply #24 on: July 02, 2008, 04:11:59 PM »
Won't correct layers.  I have a routine that will correct the layers to meet company standards if the don't.  You have to use code to do it, and I use ODBX.

Tim do you have a link to your latest routine?
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

JohnK

  • Administrator
  • Seagull
  • Posts: 10604
Re: Layer Creator Project
« Reply #25 on: July 02, 2008, 04:17:54 PM »
Yes, good work VovKa.
thanx Alan.
as to your project, i think the easiest way to read your data file is to make it compatible with read function
something like
Code: [Select]
(setq LayData (read (strcat "(" (read-line DataFile) ")")))
and remember, one day people will demand support for RGB layer colors :)
tabs could be a problem then.
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

VovKa

  • Water Moccasin
  • Posts: 1626
  • Ukraine
Re: Layer Creator Project
« Reply #26 on: July 02, 2008, 04:21:47 PM »
tabs could be a problem then.
i think not:
(read "(\"1\"\t\"2\")") -> ("1" "2")

JohnK

  • Administrator
  • Seagull
  • Posts: 10604
Re: Layer Creator Project
« Reply #27 on: July 02, 2008, 04:23:19 PM »
DBX? If your going to store your layers in a dwg then why not just insert the dwg as a block?
Won't correct layers.  I have a routine that will correct the layers to meet company standards if the don't.  You have to use code to do it, and I use ODBX.

If thats all thats required...I dont know. Im on the fence. ODBX is cool but text files are fast and easy and i dont really like keeping everything in DWGs if i dont have to (I have a hard enough time maintaining the ones i have).
What about XML?
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Layer Creator Project
« Reply #28 on: July 02, 2008, 04:24:03 PM »
James touches on a great point about ObjectDBX but the thing about it I didn't like was separation of layers into differant disciplines or differant contractors layers, etc..  That is the reason that I went with the external file(s).  And I tried to keep things simple, however the more people use it the more emails I get about wanting new features.  :ugly:

Tim, you routine is very robust.
The one thing with separate categories of layer data is that shared layers must be maintained in all files
or groups.

I suppose that using ObjectDBX or Data files there could be a common Group of Layers that always needs
to be loaded.  Also regarding groups of layers, not sure if a WCMATCH would work if you wanted to keep
all the layers in one DWG or data file.
So to separate the groups you would likely need separate files. That seems like the simplest way.
You would still need a "Common Layers" file else you must maintain all data file with common layers.
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

JohnK

  • Administrator
  • Seagull
  • Posts: 10604
Re: Layer Creator Project
« Reply #29 on: July 02, 2008, 04:25:21 PM »
tabs could be a problem then.
i think not:
(read "(\"1\"\t\"2\")") -> ("1" "2")

no i get that part, I was just thinking that we are right back to my original statement about chances for mistakes from the end user.
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org