mugshot Posted January 26, 2018 Posted January 26, 2018 Good day everyone... Got a simple problem... We have a attribute block... Used in finishings... May i ask if theres a lisp that make a code and automatically fills in? Like field tabs... What i mean is.. in a finishing code block like where u put stone(st) wood(wd) ceremic tile (ct) etc. And then code.. what i want to know is that, if u put the code st, the word stone will appear on the bottom of the block ... Thanks in advance. Quote
rlx Posted January 26, 2018 Posted January 26, 2018 the first part is simple (ok, ok, so is the rest): (defun c:tst ( / my-block input attribute-name-to-update ) (setq attribute-name-to-update "material") (princ "\nSelect your block : ") (setq my-block (car (entsel))) (setq input (strcase (getstring "\nEnter material st (stone) , wd (wood) , ct (ceramic) : "))) (cond ((equal input "ST")(setq input "Stone")) ((equal input "WD")(setq input "Wood")) ((equal input "CT")(setq input "Ceramic")) (t (princ "\nInvalid input")(setq input nil)) ) (if (and my-block input) (update_your_block myblock attribute-name-to-update input)) ) (defun update_your_block myblock (blk att val) (princ "update_your_block function under construction") ) You might also look into the initget / getkword functions (learning vs shopping ;-) ) Bottom line is : no example / no code = no (full) solution (no code, no load) gr. Rlx Quote
Grrr Posted January 26, 2018 Posted January 26, 2018 Heres another way to prompt, and call it as a command: (defun C:test ( / g tmp ) (princ "\n[s]tone | [C]eramic | [W]ood") (and (= 2 (car (setq g (grread)))) (setq tmp (vl-some '(lambda (x) (last (member (cadr g) x))) '((83 115 "Stone") (67 99 "Ceramic") (87 119 "Wood")))) (vla-SendCommand (vla-get-ActiveDocument (vlax-get-acad-object)) (strcat tmp "\n")) ) (princ) ); defun (vl-load-com) (princ) But yeah like Rlx said: Bottom line is : no example / no code = no (full) solution (no code, no load) Quote
mugshot Posted January 27, 2018 Author Posted January 27, 2018 Thanks guys... Ill try this codes..and yes, my bad. Ill post next time . Quote
BIGAL Posted January 27, 2018 Posted January 27, 2018 (edited) Like the others you can have a pop list of items rather than type at keyboard. DCL was around in 2008. This would be a library code so you could use it multiple times in a lisp so could have materials, edges, finish etc all with seperate list of items also this means have to pick from list not make a mistake in typing. This example uses one of Lee-mac's great routines. (if (not LM:listbox)(load "ListBoxV1-2.lsp")) ; loads the lisp if not already loaded (setq lst (list "Stone" "Ceramic" "Plastic")) (setq ans (nth 0 (LM:listbox "Pick material" lst 1))) ; calls the list box (alert (strcat "you have picked " ans)) ; shows what you have picked (setq lst (list "Champher" "Square" "Round")) ; 2nd list (setq ans (nth 0 (LM:listbox "Edge Style" lst 1))) (alert (strcat "you have picked" ans)) ListBoxV1-2.lsp Edited January 29, 2018 by BIGAL Quote
mugshot Posted January 29, 2018 Author Posted January 29, 2018 ..here guys..as per my query... The ST finish code and the STONE as specified final finish... What would i like to happen is that when ST is typed in, STONE will aotumatically filled in... Because my problem is that both attribute is must be edited.. Quote
mugshot Posted January 29, 2018 Author Posted January 29, 2018 Apologies for the dual post... Network probkems... ..and thanks bigal for the response... Quote
BIGAL Posted January 29, 2018 Posted January 29, 2018 Did you try the code ? Just interested. One method (cond ((if ans "Stone")(setq 2ndans "ST")) ((if ans "Ceramic")(setq 2ndans "Ce")) ((if ans "Plastic")(setq 2ndans "Pl")) ) Ok now a bit smarter when you pick from the list you can get the item number as well so Stone would be returning 0, using (nth X lst) with x as 0, a list starts at 0 so Plastic is 2. Your list is now something like this for two answers (setq lst1 (list "Stone" "ST" "Ceramic" "CE" "Plastic" "PL")) and you pass in this example nth 0, 2 & 4 to the list box. length lst / 2 is how many. So your block could have 2 attributes one hidden ST & Stone. I just need a bit of time, some one else may jump in. (setq ans (nth 0 (LM:listbox "Pick material" lst 2))) this returns the item number starts at zero so can use nth. Quote
mugshot Posted January 30, 2018 Author Posted January 30, 2018 I tried...nothing happened Maybe i cant understand where to insert these codes.. Quote
mugshot Posted January 30, 2018 Author Posted January 30, 2018 I tried...nothing happened Maybe i cant understand where to insert these codes.. Quote
BIGAL Posted January 30, 2018 Posted January 30, 2018 An example code note needs a block replace Myblock in code with your block name. (defun c:ins2atts ( / lst1 lst2 att1 att2 ans x ) (if (not LM:listbox)(load "ListBoxV1-2.lsp")) ; loads the lisp if not already loaded (setq lst1 (list "Stone" "ST" "Ceramic" "CE" "Plastic" "PL")) ; a dual list 2 items per entry (setq x 0) ; counter (setq lst '() ) ; create blank list (repeat (/ (length lst1) 2) ; how many items to be displayed in dcl list (setq lst (cons (nth x lst1) lst)) ; make list pick every second item in lst1 (setq x (+ x 2)) ; get next item ) (setq lst (reverse lst)) ; reverse list (setq ans (nth 0 (LM:listbox "Pick material" lst 2))) ; calls the list box and return item note option 2 is item (setq att1 (nth (* ans 2) lst1)) ; attribute 1 needs * 2 for correct itme number not1 1st is zero 2*0 =0 so ok (setq att2 (nth (+ (* ans 2) 1) lst1)) ; attribute 2 ;(princ (strcat "\nAttribute1= " att1 " Attribute2= " att2)) ; needs a block with 2 attributes (command "-insert" "Myblock" (getpoint) 1 1 0 att1 att2) (princ) ) (c:ins2atts) 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.