Author Topic: help:Draw lines in specific layer and then join (Y/N)  (Read 1351 times)

0 Members and 1 Guest are viewing this topic.

PM

  • Guest
help:Draw lines in specific layer and then join (Y/N)
« on: October 19, 2022, 05:23:51 AM »
Hi.I use this lisp to draw lines in specific layers. Some times i want this layers to contain  polylines (close or open). So i want to add a option at the end of the code (before change layer to 0) ,and ask me "Do you want to convert to polyline? (Y/N)"

and some way using pedit command to join them (Not all the lines in the same layer, only the lines i draw with this command)
Code: [Select]
(command "_.pedit" "_M" "" "_Y" "_J" "" "")

Code - Auto/Visual Lisp: [Select]
  1.  
  2. (defun c:test ()
  3.     (if (=(tblsearch "layer" "Layer1") nil)
  4.       (command "_layer" "_m" "Layer1" "_c" "15" "" "")
  5.      );end if
  6.      (setvar "clayer" "Layer1")
  7. (setq s1 (getpoint "\n Select fist point :" ))
  8. (while(setq s2 (getpoint s1  "\n Select next point :" ))
  9. (command "_line" "non" s1 "non" s2 "")
  10. (setq s1 s2)
  11. )
  12. ; layer to 0
  13. (mapcar 'setvar '("clayer" "cecolor" "celtype" "celweight")  (list "0" "BYLAYER" "BYLAYER" -1))
  14. )
  15.  


Thanks

PM

  • Guest
Re: help:Draw lines in specific layer and then join (Y/N)
« Reply #1 on: October 19, 2022, 04:52:12 PM »
any options?

Thanks

ronjonp

  • Needs a day job
  • Posts: 7527
Re: help:Draw lines in specific layer and then join (Y/N)
« Reply #2 on: October 19, 2022, 09:09:22 PM »
Why don't you draw polylines to start with? If in the end you want individual items simply explode it.

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

ribarm

  • Gator
  • Posts: 3265
  • Marko Ribar, architect
Re: help:Draw lines in specific layer and then join (Y/N)
« Reply #3 on: October 19, 2022, 10:31:35 PM »
Jedna zamerka Ron,...
Pri samom izgovoru eksploud... Cinjenicno je nepotrebno iskazivati Nobelizam zarad fundamentalizma...
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

PM

  • Guest
Re: help:Draw lines in specific layer and then join (Y/N)
« Reply #4 on: October 20, 2022, 02:06:39 AM »
Thanks i fix it

Code - Auto/Visual Lisp: [Select]
  1.  
  2. (DEFUN C:test (/ CONVERT  S1 S2 SS)
  3.   (if (tblsearch "layer" "Layer1")
  4.     (progn
  5.       (setq ss (ssadd))
  6.          (command "_layer" "_m" "Layer1" "_c" "15" "" "")
  7.  
  8.       (SETQ S1 (GETPOINT "\nSelect fist point ::"))
  9.       (WHILE (SETQ S2 (GETPOINT S1 "\nSelect next point :"))
  10.  (COMMAND "_line" "non" S1 "non" S2 "")
  11.  (ssadd (ENTLAST) ss)
  12.  (SETQ S1 S2)
  13.       )
  14.       (initget "Yes No")
  15.       (if (and (setq
  16.    convert (cond
  17.       ((getkword "\nConvert to  polyline? [Yes/No] <N>: "))
  18.       ("No")
  19.     )
  20.         )
  21.         (/= (sslength ss) 0)
  22.         (= convert "Yes")
  23.    )
  24.  (if (= (getvar 'PEDITACCEPT) 0)
  25.    (command "_.pedit" "_M" ss "" "_Y" "_J" "" "")
  26.    (command "_.pedit" "_M" ss "" "_J" "" "")
  27.  )
  28.       )
  29.     )
  30.   )
  31. (command "setvar" "clayer" "0")
  32. (command "-linetype" "set" "Bylayer" "")
  33.   (princ)
  34. )
  35.  
  36.  

ronjonp

  • Needs a day job
  • Posts: 7527
Re: help:Draw lines in specific layer and then join (Y/N)
« Reply #5 on: October 20, 2022, 08:53:16 AM »
Thanks i fix it

Code - Auto/Visual Lisp: [Select]
  1.  
  2. (DEFUN C:test (/ CONVERT  S1 S2 SS)
  3.   (if (tblsearch "layer" "Layer1")
  4.     (progn
  5.       (setq ss (ssadd))
  6.          (command "_layer" "_m" "Layer1" "_c" "15" "" "")
  7.  
  8.       (SETQ S1 (GETPOINT "\nSelect fist point ::"))
  9.       (WHILE (SETQ S2 (GETPOINT S1 "\nSelect next point :"))
  10.  (COMMAND "_line" "non" S1 "non" S2 "")
  11.  (ssadd (ENTLAST) ss)
  12.  (SETQ S1 S2)
  13.       )
  14.       (initget "Yes No")
  15.       (if (and (setq
  16.    convert (cond
  17.       ((getkword "\nConvert to  polyline? [Yes/No] <N>: "))
  18.       ("No")
  19.     )
  20.         )
  21.         (/= (sslength ss) 0)
  22.         (= convert "Yes")
  23.    )
  24.  (if (= (getvar 'PEDITACCEPT) 0)
  25.    (command "_.pedit" "_M" ss "" "_Y" "_J" "" "")
  26.    (command "_.pedit" "_M" ss "" "_J" "" "")
  27.  )
  28.       )
  29.     )
  30.   )
  31. (command "setvar" "clayer" "0")
  32. (command "-linetype" "set" "Bylayer" "")
  33.   (princ)
  34. )
  35.  
  36.  
Why are you doing this ?

Draw a line .. ask if it should be a polyline, repeat. Sorry I don't get your logic at all.  :wink:

FWIW, This line will prevent the code from ever running: (if (tblsearch "layer" "Layer1")
« Last Edit: October 20, 2022, 08:57:54 AM by ronjonp »

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC