ChrisAllison Posted February 25, 2015 Posted February 25, 2015 I have a block with 25 and growing attributes and correspondingglobal variables. (defun attdraw (atthandle / ) ; draw out all attributes of the insert, turn them into global variablesand fill them with (setq ent (handent atthandle) ; their corresponding data. attribute name = globalvariable name. ed (entget ent) );setq (while (/="SEQEND" (dxf 0 ed)) ;whiletag value /= SEQEND (if (="ATTRIB" (dxf 0 ed)) ;make sure its an attribute (set (read(dxf 2 ed)) (dxf 1 ed)) );if (setq ent(entnext ent) ;move to the next tag ed (entgetent) ;and get entity data );setq );while );defun i update the variables in a dialog box. exiting the dialog box i update the global variables i would like to then insert the values back into theattributes using something similar. is there a way to use the attribute names as variable namesand also use the values associated with them to push them back into theattributes. Quote
BIGAL Posted February 26, 2015 Posted February 26, 2015 You can work without attribute tag names by using the attribute creation order and then you can modify the attribute value its what is happening here (setq ent(entnext ent) ;move to the next tag, you indicate you have a dialog box so you can use order rather than tagname. As an example in VBA Attrib(3).value returns the value of the 3rd atribute. have a look at this ; Change attribute value by created position ; Eaxmple to walk trhough a block (vl-load-com) (defun blkorder ( / ss1 blobj Y) (setq y 1) (setq ss1 (car (entsel "pick block"))) (setq blobj (vlax-ename->vla-object SS1)) (foreach att (vlax-invoke blobj 'getattributes) (princ (strcat "\n attrib No " (rtos y 2 0) " " (vla-get-textstring att ))) ;(vla-put-textstring att newstrblank) ;use this to change attribute value (setq y (+ Y 1)) ) ) (blkorder) (princ) Quote
ChrisAllison Posted February 26, 2015 Author Posted February 26, 2015 How does your program find the global variables in theenvironment and associate them with the attribute name. ( i use DCL dialog boxes ifthat makes any difference). my knowledge of vl is limited to none. old school lisper Quote
BIGAL Posted February 27, 2015 Posted February 27, 2015 You have var1 = attribute value 1, say make 25 and set var1 to var25 = nil then open up block and reset the var value, only need to know how many, another way is to just create a list of the attributes, (setq lst (list 12 34 56 67 89)) var1 = (nth 0 lst) = 12 using (length lst) you always know how many variables you have. Again I do not worry about attribute TAG name but I do know order of attributes within the block. Did you try code above as an example. In VL you use a GET to do just that "get some info" and a PUT to change a value. Update in dialouge and then use ; the newstr is returned from the DCL and you know which row (foreach att (vlax-invoke blobj 'getattributes) (If (= row y) (vla-put-textstring att newstr) ) (setq y (+ Y 1)) ) ) Quote
hanhphuc Posted February 27, 2015 Posted February 27, 2015 ..growing attributes.. growing means incremental? perhaps this helps command: ATTOUT command: ATTIN 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.