Guest Posted November 6, 2022 Posted November 6, 2022 (edited) Hi i want to insert attribute block at every polyline vertices. I am writing a code but i have two problems. 1) When the code insert the block at polyline vertices at the last vertece have a duplicate block 2) I want to add a list box to select the type of the block i want to insert. This block will be already insert the drawing (defun c:test() (setq plobj (car (entsel "\nSelect Polyline: ")) inc 0); end setq (while (<= inc (vlax-curve-getEndParam plobj)) ; This lines set the scale of the block (setq scl (getvar "useri1")) (setq scl1 (* scl 0.0025)) ;====================================== (command "_.insert" "point" (vlax-curve-getPointAtParam plobj inc) scl1 "" "" "" ) (setq inc (1+ inc)) ); end while ); end defun I have this part of a code from another lisp that load the list box i want , but i don't know how to use it in the code above (defun AT:ListSelect (title label height width multi lst / fn fo d item f) ;; List Select Dialog (Temp DCL list box selection, based on provided list) ;; title - list box title ;; label - label for list box ;; height - height of box ;; width - width of box ;; multi - selection method ["true": multiple, "false": single] ;; lst - list of strings to place in list box ;; Alan J. Thompson, 09.23.08 / 05.17.10 (rewrite) (setq fo (open (setq fn (vl-filename-mktemp "" "" ".dcl")) "w")) (foreach x (list (strcat "list_select : dialog { label = \"" title "\"; spacer;") (strcat ": list_box { label = \"" label "\";" "key = \"lst\";") (strcat "allow_accept = true; height = " (vl-princ-to-string height) ";") (strcat "width = " (vl-princ-to-string width) ";") (strcat "multiple_select = " multi "; } spacer; ok_cancel; }") ) (write-line x fo) ) (close fo) (new_dialog "list_select" (setq d (load_dialog fn))) (start_list "lst") (mapcar (function add_list) lst) (end_list) (setq item (set_tile "lst" "0")) (action_tile "lst" "(setq item $value)") (setq f (start_dialog)) (unload_dialog d) (vl-file-delete fn) (if (= f 1) ((lambda (s / i s l) (while (setq i (vl-string-search " " s)) (setq l (cons (nth (atoi (substr s 1 i)) lst) l)) (setq s (substr s (+ 2 i))) ) (reverse (cons (nth (atoi s) lst) l)) ) item ) ) ) Thanks Drawing1.dwg Edited November 6, 2022 by prodromosm Quote
Guest Posted November 6, 2022 Posted November 6, 2022 (defun c:test() (setq plobj (car (entsel "\nSelect Polyline: ")) inc 0); end setq (while (<= inc (vlax-curve-getEndParam plobj)) (setq scl (getvar "useri1")) (setq scl1 (* scl 0.0025)) ; (command "_.insert" "point" (vlax-curve-getPointAtParam plobj inc) scl1 "" "" "" ) (setq block (car (AT:ListSelect "Select block to insert:" "" 10 10 "false" lst))) (setq inc (1+ inc)) ); end while ); end defun (defun AT:ListSelect (title label height width multi lst / fn fo d item f) ;; List Select Dialog (Temp DCL list box selection, based on provided list) ;; title - list box title ;; label - label for list box ;; height - height of box ;; width - width of box ;; multi - selection method ["true": multiple, "false": single] ;; lst - list of strings to place in list box ;; Alan J. Thompson, 09.23.08 / 05.17.10 (rewrite) (setq fo (open (setq fn (vl-filename-mktemp "" "" ".dcl")) "w")) (foreach x (list (strcat "list_select : dialog { label = \"" title "\"; spacer;") (strcat ": list_box { label = \"" label "\";" "key = \"lst\";") (strcat "allow_accept = true; height = " (vl-princ-to-string height) ";") (strcat "width = " (vl-princ-to-string width) ";") (strcat "multiple_select = " multi "; } spacer; ok_cancel; }") ) (write-line x fo) ) (close fo) (new_dialog "list_select" (setq d (load_dialog fn))) (start_list "lst") (mapcar (function add_list) lst) (end_list) (setq item (set_tile "lst" "0")) (action_tile "lst" "(setq item $value)") (setq f (start_dialog)) (unload_dialog d) (vl-file-delete fn) (if (= f 1) ((lambda (s / i s l) (while (setq i (vl-string-search " " s)) (setq l (cons (nth (atoi (substr s 1 i)) lst) l)) (setq s (substr s (+ 2 i))) ) (reverse (cons (nth (atoi s) lst) l)) ) item ) ) ) I update the code but need help. Thanks Quote
Scoutr4 Posted November 6, 2022 Posted November 6, 2022 (edited) I'm not sure if it will work for you, but I edited a lisp. Main lisp link : https://www.theswamp.org/index.php?topic=56484.0 PLB.LSP Edited November 6, 2022 by Scoutr4 Quote
Guest Posted November 6, 2022 Posted November 6, 2022 Hi Scoutr4. Yes this code works. Can you help me with the scale of the blocks? I use the code bellow for the scale. Thanks (setq scl (getvar "useri1")) (setq scl1 (* scl 0.0025)) Quote
Guest Posted November 7, 2022 Posted November 7, 2022 Hi Scoutr4. Is it possible to add a filter if polyline vertex have already a block, not to insert another ? Sometimes for example I have polyline with 10 vertices and the 3 of them have already a block and I want to insert block to the other seven not to all. Thanks Quote
Scoutr4 Posted November 7, 2022 Posted November 7, 2022 To check for blocks at the points, there must be a line at the base point of the blocks. If the base point is empty, with the line command click the base point and type 0,0 once. Then click escape. You will get a dot-like line. PLB.LSP Quote
Guest Posted November 7, 2022 Posted November 7, 2022 Quote You will get a dot-like line. The code works. You said something about a dot line. I can not see any dot line in the drawing !!! Can you explain me ? Thanks Quote
Scoutr4 Posted November 7, 2022 Posted November 7, 2022 There are six different blocks. Try to throw blocks with similar characteristics on the same line. You will understand the difference between the blocks. Example.dwg Quote
Guest Posted November 7, 2022 Posted November 7, 2022 I understand now. I am using dot blocks, that's why I didn't understand it !!!! Thanks Quote
BIGAL Posted November 8, 2022 Posted November 8, 2022 Rather than use "Useri1" which is integer by the way, use (setq sc (vlax-ldata-get "prodromosn" "scale")) this is saved in the dwg using (vlax-ldata-put "prodromosn" "scale" scl1) "Userr1" is a real. 1 Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.