Jump to content

LayerDirector for multiple CAD standards - use PROJECTNAME?


mig20

Recommended Posts

**I've posted this question on another site which a lot of people here frequent as well so I apologise in advance and don't expect an answer to both forums.** :oops:

 

I regularly work between four different CAD standards with their own layer sets, and I use Lee Mac's LayerDirector (Thanks Lee ;) ) with layer lists for each standard but have to reload the right one manually when I switch projects.

 

It's not the end of the world having to do this but I'd like to roll it out to other users to help enforce the correct layer usage, however I'd like it automated so they don't have to load the LayerDirector themselves.

 

My first thought was a variable in the drawing to identify the standard to be used (I thought PROJECTNAME would do it) and then LayerDirector would know what layer list to use, or set a project search path load the correct lisp.

 

Any advice or assistance would very welcome!

 

thanks :)

 

 

ps. I don't know whether to start another thread or not as it is a similar question but I currently have a tool palette for each of the CAD standards which are almost identical and allow me to run the same lisps/scripts but modified slightly for each standard. If could set a project search path which is recognised in each drawing, then I'd only need to maintain one version of the tool palette and it would find the right version of the lisp/script accordingly.

Link to comment
Share on other sites

Welcome to CADTutor; I'm delighted that you find my Layer Director so useful in your work.

 

How is the PROJECTNAME system variable associated with the name of your CAD Standard?

i.e. is the name of the CAD Standard the same as PROJECTNAME?

 

Lee

Link to comment
Share on other sites

Like Lee a simple use of variables USERI1 - USERI5 can be used to retrieve a stored value but be warned other programs may also write useri1. A better way is to use a dictionary variable

 

(setvar "USERI1" 1)
(setq layerstd (getvar "USERI1")

 

this example stores two variables wallsize and thickness

 

(defun get-or-create-Dict (/ adict)

 ;;test if "LAYSTD" is already present in the main dictionary
 (if (not (setq adict (dictsearch (namedobjdict) "LAYSTD")))

   ;;if not present then create a new one and set the main
   ;; dictionary as owner
   (progn

     (setq adict (entmakex '((0 . "DICTIONARY")(100 . "AcDbDictionary"))))

     ;;if succesfully created, add it to the main dictionary
     (if adict (setq adict (dictadd (namedobjdict) "LAYSTD" adict)))
   )

   ;;if present then just return its entity name
   (setq adict (cdr (assoc -1 adict)))
 )
)

(defun get-or-make-Xrecord (/ adict anXrec)
; change to allow w1 etc and thickness 

 (cond
    ;;first get our dictionary. Notice that "LAYSTD" will be
   ;;created here in case it doesn't exist
   ((setq adict (get-or-create-Dict))
     (cond
       ;;if "LAYSTD" is now valid then look for "LAYSTDVARS" Xrecord 
      ((not (setq anXrec (dictsearch adict wallvar))) 
;the variable LAYSTDvars is name of xrecord so need to be a variable to add lots
       ;;if "LAYSTDVARS" was not found then create it
       ;(setq anXrec (entmakex '((0 . "XRECORD")
(setq anXrec (entmakex (list (cons 0  "XRECORD")
                               (cons 100  "AcDbXrecord")
                               ;(1 . wallvar)
   (cons 1 wallvar)
   (cons 40 wallsize)
    ;(40 . wallsize)
                               )
                    )
       )
       ;;if creation succeeded then add it to our dictionary
       (if anXrec (setq anXrec (dictadd adict wallvar anXrec)))
      )
      ;;if it's already present then just return its entity name
      (setq anXrec
       (cdr (assoc -1 (dictsearch adict wallvar)))
      )
    )
   )
 )
)
(defun getLAYSTDvars (/ vars varlist)
 ;;retrieve XRecord "wallvar" from dictionary "LAYSTD"
 ;;which in turn calls both functions above
 (setq vars (get-or-make-Xrecord))

 ;;if our Xrecord is found, then get values in group code 
 (cond (vars
        (setq varlist  (entget vars))
        (setq WALLname (cdr (assoc 1 varlist)))
        (setq WALLTHICK  (cdr (assoc 40 varlist)))
       )

       ;;otherwise return nil
       (T nil)
 )
)

Link to comment
Share on other sites

Welcome to CADTutor; I'm delighted that you find my Layer Director so useful in your work.

 

How is the PROJECTNAME system variable associated with the name of your CAD Standard?

i.e. is the name of the CAD Standard the same as PROJECTNAME?

 

Lee

 

Thanks Lee, i've been a lurker on this site for a while now and now I've decided to "dive in" ;) I have been admirer of your work for some time and your LISPs and advice in posts have saved me countless hours at work.

 

 

Yes my initial thoughts are to set PROJECTNAME (or another in-drawing variable) to the CAD standard's name - eg STD1, STD2, etc - or something similar to that.

Link to comment
Share on other sites

Like Lee a simple use of variables USERI1 - USERI5 can be used to retrieve a stored value but be warned other programs may also write useri1. A better way is to use a dictionary variable

 

(setvar "USERI1" 1)
(setq layerstd (getvar "USERI1")

 

this example stores two variables wallsize and thickness

 

(defun get-or-create-Dict (/ adict)

 ;;test if "LAYSTD" is already present in the main dictionary
 (if (not (setq adict (dictsearch (namedobjdict) "LAYSTD")))

   ;;if not present then create a new one and set the main
   ;; dictionary as owner
   (progn

     (setq adict (entmakex '((0 . "DICTIONARY")(100 . "AcDbDictionary"))))

     ;;if succesfully created, add it to the main dictionary
     (if adict (setq adict (dictadd (namedobjdict) "LAYSTD" adict)))
   )

   ;;if present then just return its entity name
   (setq adict (cdr (assoc -1 adict)))
 )
)

(defun get-or-make-Xrecord (/ adict anXrec)
; change to allow w1 etc and thickness 

 (cond
    ;;first get our dictionary. Notice that "LAYSTD" will be
   ;;created here in case it doesn't exist
   ((setq adict (get-or-create-Dict))
     (cond
       ;;if "LAYSTD" is now valid then look for "LAYSTDVARS" Xrecord 
      ((not (setq anXrec (dictsearch adict wallvar))) 
;the variable LAYSTDvars is name of xrecord so need to be a variable to add lots
       ;;if "LAYSTDVARS" was not found then create it
       ;(setq anXrec (entmakex '((0 . "XRECORD")
(setq anXrec (entmakex (list (cons 0  "XRECORD")
                               (cons 100  "AcDbXrecord")
                               ;(1 . wallvar)
   (cons 1 wallvar)
   (cons 40 wallsize)
    ;(40 . wallsize)
                               )
                    )
       )
       ;;if creation succeeded then add it to our dictionary
       (if anXrec (setq anXrec (dictadd adict wallvar anXrec)))
      )
      ;;if it's already present then just return its entity name
      (setq anXrec
       (cdr (assoc -1 (dictsearch adict wallvar)))
      )
    )
   )
 )
)
(defun getLAYSTDvars (/ vars varlist)
 ;;retrieve XRecord "wallvar" from dictionary "LAYSTD"
 ;;which in turn calls both functions above
 (setq vars (get-or-make-Xrecord))

 ;;if our Xrecord is found, then get values in group code 
 (cond (vars
        (setq varlist  (entget vars))
        (setq WALLname (cdr (assoc 1 varlist)))
        (setq WALLTHICK  (cdr (assoc 40 varlist)))
       )

       ;;otherwise return nil
       (T nil)
 )
)

 

 

 

..and thanks to you as well BIGAL :)

 

As I said to Lee, my first thought is to use an existing variable that I know isn't by our team (less work on my part :) ), but failing that to make a "swtich" that the code would recognise. Your suggestion gives me that option too and something to investigate.

 

I gone from drawing a blank last night to a couple of options to try today, and helpful replies from yourself and Lee. Sometimes just airing a problem get the old grey matter working better!!

 

 

Many thanks ;)

Link to comment
Share on other sites

Thanks Lee, i've been a lurker on this site for a while now and now I've decided to "dive in" ;) I have been admirer of your work for some time and your LISPs and advice in posts have saved me countless hours at work.

 

I'm glad you've finally taken the plunge...

Thank you for your flattering comments, I'm delighted that my posts & programs have saved you time in your work.

 

Yes my initial thoughts are to set PROJECTNAME (or another in-drawing variable) to the CAD standard's name - eg STD1, STD2, etc - or something similar to that.

 

I would suggest replacing lines 45-52 (inclusive) of my Layer Director program with the following:

(setq *LayerDirector-LayerData*
   (cond
       (
           (cdr
               (assoc (getvar 'projectname)
                  '(
[color=red]                        (
                           "STD1"
                           ("[DM]TEXT,TEXT"   "TEXT"      )
                           ("DIM*,*LEADER"    "DIMENSIONS")
                           ("*VPORT*"         "DEFPOINTS" )
                       )[/color]
[color=red]                        (
                           "STD2"
                           ("[DM]TEXT,TEXT"   "TEXT"      )
                           ("DIM*,*LEADER"    "DIMENSIONS")
                           ("*VPORT*"         "DEFPOINTS" )
                       )[/color]
[color=red]                        (
                           "STD3"
                           ("[DM]TEXT,TEXT"   "TEXT"      )
                           ("DIM*,*LEADER"    "DIMENSIONS")
                           ("*VPORT*"         "DEFPOINTS" )
                       )[/color]
                   )
               )
           )
       )
       (
[color=green]           '(
               ("[DM]TEXT,TEXT"   "TEXT"      )
               ("DIM*,*LEADER"    "DIMENSIONS")
               ("*VPORT*"         "DEFPOINTS" )
           )[/color]
       )
   )
)

Here, the sections marked in red are the project-specific layer settings, with the first item in the list equal to the value of the PROJECTNAME system variable.

 

The section marked in green is the default layer settings, that is, should the value of the PROJECTNAME system variable not match an item in the first list.

 

I hope this helps!

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...