TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: PM on March 19, 2020, 09:22:38 AM

Title: Offset in new layer - Help with lisp
Post by: PM on March 19, 2020, 09:22:38 AM
Hi i am trying to write a lisp code to offset linew ,polylines in a new layer with name WALL but i have problem with the layer. The  offset line stay in the curent layer

Code - Auto/Visual Lisp: [Select]
  1. (defun c:onl (/ n ss p e)
  2. (command "_layer" "_m" "wall" "_c" "161" "" "")
  3.    (and (setq n (getdist "\n offset distance :"))
  4.         (setq
  5.           ss (ssget "_+.:S:L" '((0 . "*POLYLINE,*LINE")))
  6.         )
  7.         (setq p (getpoint "\n select point :"))
  8.    )
  9.     (progn
  10.       (command "_.offset" n ss "_non" p "")
  11.       (setq e (entlast))
  12.       (if (tblsearch "LAYER" "cover")
  13.         (command "_.chprop" e "" "_layer" "cover" "")
  14.       )
  15.     )
  16.     (princ)
  17.  )
  18. ;change layer to 0
  19. (mapcar 'setvar '(clayer cecolor celtype celweight) (list "0" "BYLAYER" "BYLAYER" -1))
  20. )
  21. )
  22.  

Any idea ?

thanks
Title: Re: Offset in new layer - Help with lisp
Post by: PM on March 19, 2020, 09:58:46 AM
any options ?
Title: Re: Offset in new layer - Help with lisp
Post by: tombu on March 19, 2020, 10:01:34 AM
Why not just use the Layer option of the OFFSET command?
Title: Re: Offset in new layer - Help with lisp
Post by: PM on March 19, 2020, 10:12:14 AM
I change the code. Is any option to continue offset multyple lines and not only one ?

Code - Auto/Visual Lisp: [Select]
  1. (defun C:NOF ( / ed lay nlay)
  2. (command "_layer" "_m" "wall" "_c" "161" "" "")
  3. (command "offset" pause pause pause "")
  4. (command "chprop" "l" "" "la" (getvar "clayer") "")
  5. ;change layer to 0
  6. (mapcar 'setvar '(clayer cecolor celtype celweight) (list "0" "BYLAYER" "BYLAYER" -1))
  7. )
  8.  
Title: Re: Offset in new layer - Help with lisp
Post by: PM on March 20, 2020, 05:16:57 AM
Hi i do some changes. I find that the faster way is to do this

Code - Auto/Visual Lisp: [Select]
  1. (defun c:OO (/ )
  2. (command "_layer" "_m" "wall" "_c" "161" "" "")
  3. (command "_OFFSET" "L" "C")
  4. )
  5.  

Works but i want after all offset then to return the curent layer to 0. But when i add after offset command

Code - Auto/Visual Lisp: [Select]
  1. ;return to  0
  2. (mapcar 'setvar '(clayer cecolor celtype celweight) (list "0" "BYLAYER" "BYLAYER" -1))
  3.  
  4.  

do the offset in the 0 layer. Can any one help me to change the current layer after all offset to 0

Thanks
Title: Re: Offset in new layer - Help with lisp
Post by: BIGAL on March 21, 2020, 02:15:43 AM
To do multiple wrap in a While see http://www.theswamp.org/index.php?topic=55863.0
Title: Re: Offset in new layer - Help with lisp
Post by: tombu on March 21, 2020, 08:30:08 AM
This works:
Code: [Select]
(defun c:OO (/ )
(command "_layer" "_m" "wall" "_c" "161" "" "")
(command "_OFFSET" "L" "C")
(while (= (getvar 'cmdnames) "OFFSET") (command PAUSE)) ; Just needed to add "PAUSE while OFFSET command is active"
(mapcar 'setvar '(clayer cecolor celtype celweight) (list "0" "BYLAYER" "BYLAYER" -1))
(princ)
)
Title: Re: Offset in new layer - Help with lisp
Post by: PM on March 21, 2020, 01:59:45 PM
Thank you tombu