Please help to modify the OFFSET AUTOLISP program

Discussion in 'AutoCAD' started by wk9128, Mar 30, 2023.

  1. wk9128

    wk9128

    Joined:
    Mar 30, 2023
    Messages:
    2
    Likes Received:
    0
    Code:
    (defun c:myoffset (/ ss offset_dis layer_entry layer_name color_name line_name confirm new_ents)
      (setq ss (ssget)
            offset_dis 0.0
            layer_name ""
            color_name ""
            line_name ""
            confirm ""
            new_ents nil)
      (if ss
          (progn
            (setq offset_dis (getdist "\nPlease offset distance: ")
                  layer_entry (tblsearch "LAYER" (cdr (assoc 8 (entget (ssname ss 0))))))
            (if layer_entry
                (setq layer_name (cdr (assoc 2 layer_entry)))
              (setq layer_name ""))
            (setq color_name (acad_colordlg 7))
            (setq line_name (strcase (strtrim (getstring t "\nPlease select a linetype for the new object:\n1.Solid line\n2.Center line\n3.Dashed line\n\nPlease enter line style options:"))))
            (setq confirm (strcase (strtrim (getstring t "\nAre you sure you want to offset the object? (Y/N): "))))
            (if (= confirm "Y")
                (progn
                  (command ".OFFSET" offset_dis ss "")
                  (setq new_ents (nentselp "\nPlease select the new object: "))
                  (vla-put-color (vlax-ename->vla-object (car new_ents)) color_name)
                  (if (= line_name "1") (command ".CHPROP" new_ents "" "LT" "continuous"))
                  (if (= line_name "2") (command ".CHPROP" new_ents "" "LT" "center"))
                  (if (= line_name "3") (command ".CHPROP" new_ents "" "LT" "dashed"))
                  (if layer_name (command ".CHPROP" new_ents "" "LA" layer_name)))
              (princ "\nOperation canceled!")))
        (princ "\nNo objects selected!"))
      (princ))
    
    (defun acad_colordlg ( init / r g b )
      (if (not (and (setq r (car init))
                    (setq g (cadr init))
                    (setq b (caddr init))))
        (setq r 255 g 255 b 255)
      )
      (vl-cmdf "_.-COLOR %d %d %d" r g b)
    Can someone please help me ? It would be much appreciated. Thanks in advance
     
    wk9128, Mar 30, 2023
    #1
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.