CafeJr Posted May 22, 2015 Posted May 22, 2015 Hi to all, Someone knows a LISP router that can write a selected text on a specific field attribute when you are inserting the block. Eg.: One Block with a field "Diameter", when I'll insert this block I can choose on a window and select what will be that diameter (1/2", 3/4", 1", 1.1/2"), but I have more than one Attribute field to insert (selecting the specific text entry), diameter, length, color... each one with a filed to choose the detail on a list. It looks like a block with a lot of blank attributes that when insert it, for each attribute you need to select on a window that specific detail. Quote
Lee Mac Posted May 22, 2015 Posted May 22, 2015 Use the attribute tag to determine which attribute reference to populate after the block reference has been inserted. You can use my Set Attribute Value function to perform this operation: supply the function with the entity name of the inserted block reference (which could be obtained using entlast depending on how you are inserting your block), the attribute tag to populate, and the attribute value to which the attribute should be set. Aside, if you are looking to populate the attribute value with a field expression, you will need to use the Visual LISP version of the linked function above, and supply the function with the vla-object representation of the block reference. Lee Quote
BIGAL Posted May 23, 2015 Posted May 23, 2015 A simple way ask all the questions first via lisp then when you "INSERT Blockname" you respond with the attribute values as lisp variables. (setq ans1 (getstring)) ; repeat for each required atrribute ; call the dcl lists here etc (Command "Insert" "blockname" (getpoint) 1 1 0 ans1 ans2 ans3 "" ans4 "") ; note blank entries also An old fashioned way that has nearly gone is that you can have screen menus that are populated with values like your 1/2 1/4 1/8 and you pick them as responces when doing normal autocad commands I had very little succes last time, Autocad as a default makes the screen menus turned off. Vey easy to make a pity it has not been supported properly. macro something like this ^c^cscreenmenu fracs INSERT Quote
CafeJr Posted May 25, 2015 Author Posted May 25, 2015 Use the attribute tag to determine which attribute reference to populate after the block reference has been inserted. You can use my Set Attribute Value function to perform this operation: supply the function with the entity name of the inserted block reference (which could be obtained using entlast depending on how you are inserting your block), the attribute tag to populate, and the attribute value to which the attribute should be set. Aside, if you are looking to populate the attribute value with a field expression, you will need to use the Visual LISP version of the linked function above, and supply the function with the vla-object representation of the block reference. Lee Thank you Lee... I'll try it... Quote
CafeJr Posted May 25, 2015 Author Posted May 25, 2015 A simple way ask all the questions first via lisp then when you "INSERT Blockname" you respond with the attribute values as lisp variables. (setq ans1 (getstring)) ; repeat for each required atrribute ; call the dcl lists here etc (Command "Insert" "blockname" (getpoint) 1 1 0 ans1 ans2 ans3 "" ans4 "") ; note blank entries also An old fashioned way that has nearly gone is that you can have screen menus that are populated with values like your 1/2 1/4 1/8 and you pick them as responces when doing normal autocad commands I had very little succes last time, Autocad as a default makes the screen menus turned off. Vey easy to make a pity it has not been supported properly. macro something like this ^c^cscreenmenu fracs INSERT Bigal, thanks too much!!!... I also will try!!!... Quote
CafeJr Posted May 25, 2015 Author Posted May 25, 2015 Dears Lee and Bigal, I was studying the codes, so what I have is one dwg file that has a group of blocks and I need to insert one of them selecting it, as I choose the block to be inserted, It's necessary to select the attribute fields to populate it as a checkbox with a selection list also repeating it with a number of attributes fields to be populated. I do not know if I was clear, please, let me know. I understood how to populate a attribute field, but how can I create a checkbox or a selection list to do it?... I need to create for each block in this drawing the attribute fields, but how to link it with the checkbox? Quote
BIGAL Posted May 26, 2015 Posted May 26, 2015 Again using a lisp it can be done, you need to be able to code Dialouges to do what you want start simple by searching for using a DCL LIST box for input. Lee may have a sample, You use a generic dcl but pass the name of the list to be used. I would post but just don't have one at hand have to pull apart some code. Quote
CafeJr Posted May 29, 2015 Author Posted May 29, 2015 (edited) Dears, Bigal and Lee... I'm again needing your help, I found this CODE (thanks to Kenny Ramage's code), and I change this to use, but I got some problems with them (in red): DCL file> samp5 : dialog { //dialog name label = "Structural Holes" ; //give it a label : row { //*define row : boxed_radio_column { //define radio column label = "TIPO" ; //give it a label [color="red"]: radio_button { //define radion button key = "rb1" ; //give it a name label = "C" ; //give it a label value = "1" ; //switch it on } //end definition[/color] : radio_button { //define radio button key = "rb2" ; //give it a name label = "E" ; //give it a label } //end definition : radio_button { //define radio button key = "rb3" ; //give it a name label = "LB" ; //give it a label } //end definition : radio_button { //define radio button key = "rb4" ; //give it a name label = "LL" ; //give it a label } //end definition : radio_button { //define radio button key = "rb5" ; //give it a name label = "LR" ; //give it a label } //end definition : radio_button { //define radion button key = "rb6" ; //give it a name label = "T" ; //give it a label } //end definition : radio_button { //define radion button key = "rb7" ; //give it a name label = "X" ; //give it a label } //end definition } //end radio column : boxed_column { //*define boxed column label = "&Size" ; //*give it a label : popup_list { //*define popup list key = "selections" ; //*give it a name value = "1" ; //*initial value } //*end list } //*end boxed column } //*end row [color="red"] : toggle {key = "tog1" ; //selection toggle value = 0 ; //no selection label = "Sobe - S";} : toggle {key = "tog2" ; //selection toggle value = 0 ; //no selection label = "Desce - D";} [/color] ok_cancel ; //predifined OK/Cancel : row { //define row : image { //define image tile key = "im" ; //give it a name height = 1.0 ; //and a height width = 1.0 ; //and now a width } //end image : paragraph { //define paragraph : text_part { //define text label = "Designed and Created" ; //give it some text } //end text : text_part { //define more text label = "by Kenny Ramage" ; //some more text } //end text } //end paragraph } //end row } //end dialog Here it's OK, I got how to work with it!... LISP file> (vl-load-com) (defun C:samp5 () ;define function (setq SIZ "3/4\"") ;*preset hole size (setq NAMES '("1/2\"" "3/4\"" "1\"" "1.1/2\"" "2\"" "2.1/2\"" "3\"" "4\"") ;*define list );setq (setq dcl_id (load_dialog "samp5.dcl")) ;load dialog (if (not (new_dialog "samp5" dcl_id) ;test for dialog );not (exit) ;exit if no dialog );if (setq w (dimx_tile "im") ;get image tile width h (dimy_tile "im") ;get image tile height );setq (start_image "im") ;start the image (fill_image 0 0 w h 5) ;fill it with blue (end_image) ;end image (start_list "selections") ;*start the list box (mapcar 'add_list NAMES) ;*fill the list box (end_list) ;*end list [color="red"](action_tile "rb1" "(setq hole \"C\")") ;store hole type[/color] (action_tile "rb2" "(setq hole \"E\")") ;store hole type (action_tile "rb3" "(setq hole \"LB\")") ;store hole type (action_tile "rb4" "(setq hole \"LL\")") ;store hole type (action_tile "rb5" "(setq hole \"LR\")") ;store hole type (action_tile "rb6" "(setq hole \"T\")") ;store hole type (action_tile "rb7" "(setq hole \"X\")") ;store hole type (action_tile "tog1" "(setq Sobe $value)") (action_tile "tog2" "(setq Desce $value)") (action_tile "cancel" ;if cancel button pressed "(done_dialog) (setq userclick nil)" ;close dialog, set flag ) ;action_tile (action_tile "accept" ;if O.K. pressed (strcat ;string 'em together "(progn (setq SIZ (atof (get_tile \"selections\")))" ;get list selection -> (setq SIZ (atof (get_tile \"selections\")))" " (done_dialog)(setq userclick T))" ;close dialog, set flag ) ;strcat ) ;action tile (start_dialog) ;start dialog (unload_dialog dcl_id) ;unload (if userclick ;*check O.K. was selected [color="red"](if (AND (= (atoi Sobe) 1) (= (atoi Desce) 1) ) (alert "ERROR: check only S or D!") ***Back to the window selection[/color] (progn (setq SIZ (fix SIZ)) ;*convert to integer (setq SIZ (nth SIZ NAMES)) ;*get the size (setq blockname (strcat "Condulete-" hole)) (Command "Insert" blockname (getpoint) 1 1 0 (strcat hole "-%%C" SIZ)) );progn [color="red"])[/color] );if userclick (princ) );defun C:samp (princ) So, the selected item rb1 "item 1 - C", doesn't work; At end of code I use it (it works!!!) - I'll use other field attributes to complement it: (setq blockname (strcat "Condulete-" hole)) (Command "Insert" blockname (getpoint) 1 1 0 SIZ) (princ) ; (princ hole) ; (princ "_") ; (princ SIZ) );defun C:samp (princ) THANKS a lot to you!!!... Edited June 2, 2015 by CafeJr Updated the code Quote
BIGAL Posted May 30, 2015 Posted May 30, 2015 Look at using a list dialouge. Lee has sample code this way you have only 1 DCL description "list_box" and this is populated with your NAMES you can return the value "1/2" or its row position and then use Nth. If you want 0.5 rather than "1/2" Here is a example two parts the lsp I have cut out of a bigger program for simplicity so dont try to run. (IF (> LENLST 1) (PROGN (SETQ POINTSPICK (CAR (AT:LISTSELECT "SET NEW GROUP " "SELECT POINTS GROUP" 10 10 "FALSE" (VL-SORT (MAPCAR (FUNCTION CAR) LST) '<) ))) ) ; END PROGN ) ;END IF And the DCL (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) Quote
CafeJr Posted June 2, 2015 Author Posted June 2, 2015 (edited) Look at using a list dialouge. Lee has sample code this way you have only 1 DCL description "list_box" and this is populated with your NAMES you can return the value "1/2" or its row position and then use Nth. If you want 0.5 rather than "1/2" Here is a example two parts the lsp I have cut out of a bigger program for simplicity so dont try to run. Thanks Bigal I got it!... When I can do this code operate, I'll do the changes to try to be it more professional... He he he... To this code I'm having two problems, I change the post #8 to a new version: 1 - The item in red doesn't work - the selection of the first item; 2 - I need to check two toggle selections to do one action, but I'm also having a problem... Edited June 2, 2015 by CafeJr Quote
CafeJr Posted June 8, 2015 Author Posted June 8, 2015 (edited) Hello, I put that lazy code to work... He he he... But I still having problem with the first item!... Even I writing on DCL code to the first item be selected as soon as the code are running, and write on LISP code to set it as below, the first selection doesn't happen and any other execution (without click on radio_button choice) will repeat the last one choice. DCL: : radio_button { //define radion button key = "rb1" ; //give it a name label = "C" ; //give it a label [color="red"]value = "1" ; //switch it on (don't work! - it's necessary click to select and confirm it)[/color] } //end definition LISP: (set_tile "rb1" "1") Edited June 9, 2015 by CafeJr 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.