Author Topic: Offset in new layer - Help with lisp  (Read 1862 times)

0 Members and 1 Guest are viewing this topic.

PM

  • Guest
Offset in new layer - Help with lisp
« 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

PM

  • Guest
Re: Offset in new layer - Help with lisp
« Reply #1 on: March 19, 2020, 09:58:46 AM »
any options ?

tombu

  • Bull Frog
  • Posts: 288
  • ByLayer=>Not0
Re: Offset in new layer - Help with lisp
« Reply #2 on: March 19, 2020, 10:01:34 AM »
Why not just use the Layer option of the OFFSET command?
Tom Beauford P.S.M.
Leon County FL Public Works - Windows 7 64 bit AutoCAD Civil 3D

PM

  • Guest
Re: Offset in new layer - Help with lisp
« Reply #3 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.  

PM

  • Guest
Re: Offset in new layer - Help with lisp
« Reply #4 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

BIGAL

  • Swamp Rat
  • Posts: 1396
  • 40 + years of using Autocad
Re: Offset in new layer - Help with lisp
« Reply #5 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
A man who never made a mistake never made anything

tombu

  • Bull Frog
  • Posts: 288
  • ByLayer=>Not0
Re: Offset in new layer - Help with lisp
« Reply #6 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)
)
Tom Beauford P.S.M.
Leon County FL Public Works - Windows 7 64 bit AutoCAD Civil 3D

PM

  • Guest
Re: Offset in new layer - Help with lisp
« Reply #7 on: March 21, 2020, 01:59:45 PM »
Thank you tombu