Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

lisp routine does not work in "autocad building design suite 2013"

4 REPLIES 4
SOLVED
Reply
Message 1 of 5
beheer
591 Views, 4 Replies

lisp routine does not work in "autocad building design suite 2013"

he people,

 

we are using some lisp routines (made for the company).  we make layer names by icon and set it current for use.

the problem with the routines is that i cannot make a selection before using the routine.

in the standard autocad 2013 it works fine but not in the building design suite 2013).

 

i copied a part of the routine (see below). (the other part is with more types of layer names).

 

i want to make an selection before i make a new layer. so that the selection goes directly into the new layer.

 

can somebody help.

 

 

(defun c:LR30() (MO:LAYER "A--LWRD--30" "1" "30WRD") (princ))

(defun c:LB30() (MO:LAYER "A--LWBDBO--30" "1" "30WBDBO") (princ))

(defun c:LB60() (MO:LAYER "A--LWBDBO--60" "1" "60WBDBO") (princ))

 

(defun MO:LAYER (name color linetype / s1 curlay l1)

(setvar 'cmdecho 0)

(if (/= (setq s1 (ssget "i")) nil)

     (setq curlay (getvar 'clayer)) )

(if (/= (setq l1 (tblsearch "layer" name)) nil)  

(if (/= (cdr (assoc 70 l1)) 0)   

(progn   

(command "-layer" "T" name "S" name "")   

(princ (strcat "\nLaag " name " is ontdooit."))   

)   

 

(command "-layer" "S" name "")

 )  

(command "-layer" "N" name "C" color name "L" Linetype name "S" name "")

)

(setvar 'cecolor "bylayer")

(setvar 'celtype "bylayer")

(if (or (= (substr name 5 2) "$8")(= (substr name 5 2) "$3"))

(command "-layer" "P" "N" name "")

)

 

(if (/= s1 nil)  

(progn

(command "laycur" s1 "")  

(setvar 'clayer curlay)  

(setq name curlay)  )

)

 

(princ (strcat "\n" name " is nu de current layer.")) )

4 REPLIES 4
Message 2 of 5
Kent1Cooper
in reply to: beheer


@beheer wrote:

....

in the standard autocad 2013 it works fine but not in the building design suite 2013).

....   

(command "-layer" ....


I'm not sure whether it will solve the pre-selection issue, but one thing that I know is true of Architectural Desktop, and that I suspect therefore may also be true of the Building Design Suite, is that it redefines the Layer command.  It doesn't recognize Layer in a (command) function unless you force it to dig back to the native AutoCAD command, with a preceding period/decimal before the command name.  Try changing all instances of the above to:

 

(command "_.layer" ....

 

[The underscore may be expendable for you -- it makes it work in other-language versions, and a lot of people include it on this forum for the sake of those users.  The hyphen is expendable in this situation, but doesn't hurt, though it may work only in some positions -- I know it will work between the period and the command name.]

Kent Cooper, AIA
Message 3 of 5
Kent1Cooper
in reply to: beheer

And some other suggestions [which may or may not affect the pre-selection problem]....

 

(if (/= something nil) ...

is more complicated than necessary.  If anything other than nil is returned by something, the test will be satisfied.  So you can just do:

(if something ...

 

It's not really necessary to test whether a Layer exists, or whether it's frozen or current.  You can just Thaw it and Make it.  If it doesn't exist yet, the Thaw option will just give a message that it didn't find it, but it will go on to the next option.  If it already exists, the Make option will give a message to that effect, but it will just go on to the next option.  Neither situation will cause an error or failure.  The Make option will set it current, and turn it on if it's off, and it will be the default for color and linetype assignments, so you don't need to repeat the name there.  You need to Thaw it before Making it, because if it exists but is Frozen, Make will have a problem because it won't be able to set it current.  [The only situation in which the following approach should not be used is if a User might have a different color or linetype already applied to that Layer, and you want to let them keep those non-standard settings.]

 

You should be able to reduce that routine to this:

 

(defun MO:LAYER (name color linetype / s1 curlay)
  (setvar 'cmdecho 0)
  (if (setq s1 (ssget "i"))
    (setq curlay (getvar 'clayer)); then
  ); if
  (command "_.layer" "T" name "M" name "C" color "" "L" linetype "" "")
  (setvar 'cecolor "bylayer")
  (setvar 'celtype "bylayer")
  (if (member (substr name 5 2) '("$8" "$3"))
    (command "_.layer" "P" "N" name ""); then
  )
  (if s1
    (progn ; then
      (command "laycur" s1 "")
      (setvar 'clayer curlay)
      (setq name curlay)
    ); progn
  ); if
  (princ (strcat "\n" name " is nu de current layer."))
); defun

 

EDIT:  You might consider changing the sequence at the end to this:

....

  (if s1
    (progn ; then
      (command "laycur" s1 "")
      (setvar 'clayer curlay)
      (setq name curlay)
    ); progn
    (princ (strcat "\n" name " is nu de current layer.")); else
  ); if
); defun

 

since there doesn't seem to be much point in reporting what the current Layer is when there was a pre-selection, and it has just changed the Layer back to what it was.  It may as well report that only if there was no pre-selection, so it has changed it and left it changed.

Kent Cooper, AIA
Message 4 of 5
beheer
in reply to: beheer

hey Kent,

 

i changed the "layer" into "_.layer" and the works fine again when i make a selection before the command.

 

so thanxs for the help.

 

Maurice.

Message 5 of 5
Kent1Cooper
in reply to: beheer


@beheer wrote:

hey Kent,

 

i changed the "layer" into "_.layer" and the works fine again when i make a selection before the command.

 

so thanxs for the help.

 

Maurice.


You're welcome.  I have taken to simply always including the _. before command names, as a general principle.

Kent Cooper, AIA

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost