Jump to content

All Activity

This stream auto-updates

  1. Past hour
  2. pkenewell

    join mtext with leader

    Did you increase the Fuzz factor value? The MTEXT objects may be further away from the leader ends than the default 0.1, which if you are working in mm is a pretty small value.
  3. HypnoS

    Need better multiline

    Ill look into them, although I would appreciate if someone would at least fix this bug i mentioned.
  4. Today
  5. JeJe

    join mtext with leader

    The lisp doesn't work for me 2393 Leaders Selected : 0 MTEXT objects associated.
  6. mhy3sx

    Help with the code : 2d stair

    Thanks for the help DATVO and Saxlle.
  7. Saxlle

    Help with the code : 2d stair

    @mhy3sx I made the same command (I hope the ZWCAD have the same functions as AutoCAD), but with the less line code and a different approach. It works the same as @DATVO modified your code, the result is the same. ; ******************************************************** ; Functions : stair2D ; Description : Drawing 2D stairs between two LINE ; Author : SAXLLE ; Date : August 07, 2025 ; ******************************************************** (prompt "\nTo run a LISP type: stair2D") (princ) (defun c:stair2D ( / old_osmode old_aunits old_layer flag ent pt1 pt2 pt3 dist num_steps equal_offset half_dist ang new_ang circle_radius off npt midptdel midptbase val midpt1 midpt2 midpt3 answ) (setq old_osmode (getvar 'osmode) old_aunits (getvar 'aunits) old_layer (getvar 'clayer) ) (setvar 'aunits 0) (setq flag T) (while (not (equal flag nil)) (setvar 'osmode 1) (setq ent (car (entsel "\nSelecte the BASE line:\n"))) (while (or (equal ent nil) (not (equal (cdr (assoc 0 (entget ent))) "LINE"))) (prompt "Try again...") (princ) (setq ent (car (entsel "\nSelecte the BASE line:\n"))) ) (setq pt1 (getpoint "\nPick the first point of the BASE line:\n") pt2 (getpoint pt1 "\nPick the second point of the BASE line:\n") pt3 (getpoint pt1 "\nGet the distance between BASE line and PARALLEL line:\n") dist (distance pt1 pt3) num_steps (getint "\nEnter the number of STEPS:") equal_offset (/ (getpropertyvalue ent "Length") num_steps) half_dist (/ dist 2) ang (angle pt1 pt2) new_ang (angle pt1 pt3) circle_radius 0.06 off 0.0 npt (list) ) (setvar 'osmode 0) (if (not (tblsearch "LAYER" "STAIR")) (command "_-layer" "_m" "STAIR" "_c" "90" "" "") (setvar 'clayer "STAIR") ) (command-s "_UNDO" "begin") (setq midptdel (mapcar '* (mapcar '+ pt1 pt3) '(0.5 0.5))) (command-s "_ERASE" midptdel "") (command-s "_LINE" pt1 (strcat "@" (rtos dist 2 2) "<" (angtos new_ang)) "") (setq midptbase (mapcar '* (mapcar '+ (getpropertyvalue (entlast) "StartPoint") (getpropertyvalue (entlast) "EndPoint")) '(0.5 0.5))) (command-s "_CIRCLE" midptbase circle_radius "") (repeat num_steps (setq val (vlax-curve-getPointAtDist (vlax-ename->vla-object ent) off) npt (append npt (list val)) off (+ off equal_offset) ) ) (setq npt (reverse npt)) (foreach pt npt (command-s "_LINE" pt (strcat "@" (rtos dist 2 2) "<" (angtos new_ang)) "") ) (setq midpt (mapcar '* (mapcar '+ (getpropertyvalue (entlast) "StartPoint") (getpropertyvalue (entlast) "EndPoint")) '(0.5 0.5)) midpt1 (mapcar '* (mapcar '+ (getpropertyvalue (entlast) "StartPoint") midpt) '(0.5 0.5)) midpt2 (mapcar '* (mapcar '+ (getpropertyvalue (entlast) "EndPoint") midpt) '(0.5 0.5)) midpt3 (polar midpt ang (/ half_dist 2)) ) (command-s "_LINE" midptbase (strcat "@" (rtos (getpropertyvalue ent "Length") 2 2) "<" (angtos ang)) "") (command-s "_LINE" midpt1 midpt3 midpt2 "") (command-s "_UNDO" "end") (initget 1 "Yes No Undo") (setq answ (getkword "\Do you want to continue? [Yes/No/Undo]")) (cond ((equal answ "No") (setq flag nil) ) ((equal answ "Undo") (command-s "_UNDO" "") ) ) (setvar 'osmode 1) ) (command-s "_regen") (setvar 'osmode old_osmode) (setvar 'aunits old_aunits) (setvar 'clayer old_layer) (prompt "\nThe 2D stairs are drawn!") (princ) ) This is the example video. STAIR2D.mp4 Best regards.
  8. Here is the code @mhy3sx, based on your original file. I've modified a few lines using a different approach, but the result remains the same. If you find this helpful, feel free to visit my page where I share tools designed to improve efficiency and save time, as effortlessly as enjoying a cup of coffee: https://lispautocad.gumroad.com/ ;; Modified by DV. Visit my page at: https://lispautocad.gumroad.com/ (defun c:Stair2D (/ p1 p2 ent start_pt end_pt mid_pt line_length circle_diameter num_steps i move_vec array_vec step_vec last_start_pt last_end_pt last_mid_pt mid1mid2_vec mid1mid2_length unit_vec perp_vec arrow_p1 arrow_p2 arrow_p3) (vl-load-com) (setvar "CMDECHO" 0) (command "._UNDO" "_BEGIN") (if (not (tblsearch "LAYER" "STAIR")) (command "_layer" "_m" "STAIR" "_c" "90" "" "") ) (setvar "CLAYER" "STAIR") (princ "\nSelect the first LINE of the staircase: ") (while (not (setq ent (ssget ":S" '((0 . "LINE"))))) (princ "\nTry again!! ") ) (command "._CHANGE" ent "" "_P" "_LA" "STAIR" "") (setq ent (ssname ent 0)) (setq ent_data (entget ent)) (setq start_pt (cdr (assoc 10 ent_data))) (setq end_pt (cdr (assoc 11 ent_data))) (setq mid_pt (mapcar '(lambda (a b) (/ (+ a b) 2.0)) start_pt end_pt)) (setq line_length (distance start_pt end_pt)) (setq circle_diameter (/ line_length 10.0)) (princ "\nSelect the start of the staircase: ") (setq p1 (getpoint)) (princ "\nSelect the end of the staircase: ") (setq p2 (getpoint p1)) (initget 7) (setq num_steps (getint "\nEnter the number of steps: ")) (setq array_vec (mapcar '- p2 p1)) (setq step_vec (mapcar '(lambda (x) (/ x num_steps)) array_vec)) (setq i 1) (while (<= i num_steps) (setq move_vec (mapcar '(lambda (x) (* x i)) step_vec)) (command "._COPY" ent "" "_non" (list 0 0 0) "_non" move_vec) (setq i (1+ i)) ) ;; Circle and arrow line (command "._CIRCLE" mid_pt (/ circle_diameter 2.0)) (setq last_start_pt (mapcar '+ start_pt (mapcar '(lambda (x) (* x num_steps)) step_vec))) (setq last_end_pt (mapcar '+ end_pt (mapcar '(lambda (x) (* x num_steps)) step_vec))) (setq last_mid_pt (mapcar '(lambda (a b) (/ (+ a b) 2.0)) last_start_pt last_end_pt)) (command "._LINE" mid_pt last_mid_pt "") (setq mid1mid2_vec (mapcar '- last_mid_pt mid_pt)) (setq mid1mid2_length (distance mid_pt last_mid_pt)) (if (> mid1mid2_length 0) (progn (setq unit_vec (mapcar '(lambda (x) (/ x mid1mid2_length)) mid1mid2_vec)) (setq perp_vec (list (- (cadr unit_vec)) (car unit_vec) 0.0)) (setq arrow_p1 (mapcar '+ last_mid_pt (mapcar '(lambda (x) (* x 0.10 mid1mid2_length)) unit_vec))) (setq arrow_p2 (mapcar '+ last_mid_pt (mapcar '(lambda (x) (* x -0.15 mid1mid2_length)) perp_vec))) (setq arrow_p3 (mapcar '+ last_mid_pt (mapcar '(lambda (x) (* x 0.15 mid1mid2_length)) perp_vec))) (command "._LINE" arrow_p1 arrow_p2 "") (command "._LINE" arrow_p1 arrow_p3 "") ) ) (command "._UNDO" "_END") (setvar "CMDECHO" 1) (setvar "CLAYER" "0") (princ) )
  9. Yesterday
  10. Hello World. I've used all the swear words I know and this block still won't behave! When I use the Move grip and pull this block all the way up, it should extend by 5-7/8" ... instead it extends by 5-3/4" and also moves 1/8" from the Basepoint. Any clue what's going on here? Thanks in advance y'all!!! jack.dwg
  11. mhy3sx

    Help with the code : 2d stair

    Hi DATVO. Yes , I update my code to work only for the left side every time.How you do it? Can you post the code? Thanks
  12. @HypnoS,, Glad to know. My version do not INSERT , just copy as you asked at the OP. Seem to be you need to make RISERS.
  13. The OP disappeared without answering any questions.
  14. A word of warning, bedit/attsync might change the block handles, but not always. I'm not sure what triggers it.
  15. Thank you very much BIGAL!! I really appreciate it! I didn't run the code yet, but I analysed it - are there 2 redundant procedures? ColumnRow and Alfa2Number that is only used in ColumnRow?
  16. Does this match your expectations?
  17. I will add the set property later but this is front end as an example, just copy all the code and paste to command line . (defun wow ( / fo ) (setq fo (open (setq fname (vl-filename-mktemp "" "" ".dcl")) "w")) (write-line " dyntruss : dialog { " fo) (write-line " label = \"Enter Values\" ; " fo) (write-line " : column { " fo) (write-line " width =25; " fo) (write-line " spacer_1 ; " fo) (write-line " : edit_box { " fo) (write-line " key = \"key1\" ; " fo) (write-line " label = \"Length \" ; " fo) (write-line " edit_width = 5; " fo) (write-line " edit_limit = 4; " fo) (write-line " is_enabled = true ; " fo) (write-line " allow_accept=true ; " fo) (write-line " } " fo) (write-line " spacer_1 ; " fo) (write-line " : edit_box { " fo) (write-line " key = \"key2\" ; " fo) (write-line " label = \"Angle \" ; " fo) (write-line " edit_width = 5; " fo) (write-line " edit_limit = 4; " fo) (write-line " is_enabled = true ; " fo) (write-line " allow_accept=true ; " fo) (write-line " } " fo) (write-line " spacer_1 ; " fo) (write-line " : radio_row { " fo) (write-line " : radio_button { " fo) (write-line " key = \"Rb1\" ; " fo) (write-line " label = \"Flipped\" ; " fo) (write-line " } " fo) (write-line " spacer_1 ; " fo) (write-line " : radio_button { " fo) (write-line " key = \"Rb2\" ; " fo) (write-line " label = \"No Flip\" ; " fo) (write-line " } " fo) (write-line " spacer_1 ; " fo) (write-line " } " fo) (write-line " spacer_1 ; " fo) (write-line " ok_cancel ; " fo) (write-line " } " fo) (write-line " } " fo) (close fo) (setq dcl_id (load_dialog fname)) (if (not (new_dialog "dyntruss" dcl_id) ) (exit) ) (set_tile "key1" "10") (set_tile "key2" "0") (set_tile "Rb1" "1") (action_tile "accept" "(setq val1 (atof (get_tile \"key1\")))(setq val2 (atof (get_tile \"key2\")))(setq val3 (get_tile \"Rb1\"))(done_dialog)") (action_tile "cancel" "(setq cancel \"yes\")(done_dialog)") (start_dialog) (unload_dialog dcl_id) (vl-file-delete fname) (if (= val3 "1")(setq visibilty "Flip")(setq visibilty "Noflip")) (princ) ) (wow)
  18. Thanks @devitg it works great!
  19. Maybe this. Does numbers and alphas, as well as a square or circle. Pt num bubble.lsp
  20. You don't use a look up table, as you mentioned just answer the question for length, then add the various blocks selecting the visibility state, you insert the block then call the dcl so can pick which visibility you want then its updated much easier that picking the Blue square and then selecting visibility. Post a new sample dwg with the separate blocks maybe a couple of different structures. Then can look at automating it.
  21. Last week
  22. ... And the system variable would still remains you set it firstly. Right?
  23. Hi I am writting a lisp to draw 2d stair. The idea is to select the fist step --> move it to layer STAIR then pick two points for the length of the stair and give the number of the steps. Then the code draw the stair with direction arrow in the middle. The code work perfect if i select the two points only from the one side of the stair. Is not all the time the left or the right side depends of the rotation. Can any one help me to update the code to work for bouth sides and don't misalign the steps. Here is the code . By the way i use ZWCAD. (defun c:Stair2D (/ p1 p2 ent ent_data step_start step_end step_vec stair_vec num_steps i base_pt new_p1 new_p2 mid1 mid2 last_base last_p1 last_p2 arrow_p1 arrow_p2 arrow_p3) (vl-load-com) (setvar "CMDECHO" 0) (command "._UNDO" "_BEGIN") (if (not (tblsearch "LAYER" "STAIR")) (command "_layer" "_m" "STAIR" "_c" "90" "" "") ) (setvar "CLAYER" "STAIR") (princ "\nSelect the first step of the staircase: ") (while (not (setq ent (ssget ":S" '((0 . "LINE"))))) (princ "\nTry again!! ") ) (command "._CHANGE" ent "" "_P" "_LA" "STAIR" "") (setq ent_data (entget (ssname ent 0))) (setq step_start (cdr (assoc 10 ent_data))) (setq step_end (cdr (assoc 11 ent_data))) (setq step_vec (mapcar '- step_end step_start)) (setvar "OSMODE" 1) (setq p1 (getpoint "\nSelect the start of the staircase: ")) (setq p2 (getpoint p1 "\nSelect the end of the staircase: ")) (setvar "OSMODE" 0) (initget 7) (setq num_steps (getint "\nEnter the number of steps: ")) (setq stair_vec (mapcar '(lambda (a b) (/ (- b a) num_steps)) p1 p2)) (setq i 1) (while (<= i num_steps) (setq base_pt (mapcar '+ p1 (mapcar '(lambda (x) (* x i)) stair_vec))) (setq new_p1 base_pt) (setq new_p2 (mapcar '+ base_pt step_vec)) (command "._LINE" new_p1 new_p2 "") (setq i (1+ i)) ) (setq mid1 (mapcar '(lambda (a b) (/ (+ a b) 2.0)) step_start step_end)) (setq last_base (mapcar '+ p1 (mapcar '(lambda (x) (* x num_steps)) stair_vec))) (setq last_p1 last_base) (setq last_p2 (mapcar '+ last_base step_vec)) (setq mid2 (mapcar '(lambda (a b) (/ (+ a b) 2.0)) last_p1 last_p2)) (command "._line" mid1 mid2 "" "" "_N") (command "._CIRCLE" mid1 0.06) (setq mid1mid2_vec (mapcar '- mid2 mid1)) (setq mid1mid2_length (distance mid1 mid2)) (setq unit_vec (mapcar '(lambda (x) (/ x mid1mid2_length)) mid1mid2_vec)) (setq perp_vec (list (- (cadr unit_vec)) (car unit_vec) 0.0)) (setq arrow_p1 (mapcar '+ mid2 (mapcar '(lambda (x) (* x 0.10)) unit_vec))) (setq arrow_p2 (mapcar '+ mid2 (mapcar '(lambda (x) (* x -0.15)) perp_vec))) (setq arrow_p3 (mapcar '+ mid2 (mapcar '(lambda (x) (* x 0.15)) perp_vec))) (command "._LINE" arrow_p1 arrow_p2 "") (command "._LINE" arrow_p1 arrow_p3 "") (command "._UNDO" "_END") (setvar "CMDECHO" 1) (setvar "CLAYER" "0") (princ) ) Thanks Drawing2.dwg
  24. First, the code sets CMDECHO to 0 to prevent program from displaying commands like MLEADER or its interactions in the command line. This helps keep cleaner while the program runs. At the end of the program, the code resets CMDECHO to 1, which is AutoCAD's default setting. I copied my old file into this one, so I probably forgot to remove that line. But in this code, it's not necessary. The command will cancel.
  25. Good start. A few points if you like: - what would happen if a user pressed ESC while Mleader command is active? - What's the need of function vl-load-com in your routine? - You assumed that the system variable CMDECHO was set to 1 but it could be the contrary.
  26. Problem is we cannot always set the length prior to flip as we need to find the right size after the flip. I am trying a few different methods hopefully I can get this to work
  27. @HypnoS use the previous, reattached, It will ask for distance only once , and ask for the straight line start point to paste each block cpy-blk-2-poly.lsp copy block 2 poly 2025-08-05 10-37-41.rar
  1. Load more activity
×
×
  • Create New...