Da Ballz Posted August 28, 2015 Share Posted August 28, 2015 (edited) I'm trying to build a string using a specified prefix (user defined variable) and the file name. I then want to set the string as a variable and pass it to an attribute as the new value. Here is a bit of the code so far: (if (setq ss (ssget "X" '((0 . "insert")(2 . "Drawing_Sheet_*,")))) (progn (while (> (sslength ss) 0) (setq ent (ssname ss 0)) (ssdel ent ss) (setq pre "100-") (setq drawing (substr (getvar "dwgname") 1 (- (strlen (getvar "dwgname")) 4))) (setq drawingname (strcat pre drawing)) (ATT:REPLACE ent '( ;ATT:REPLACE works, it's define above in the larger function ("Drawing_Number" . "drawingname") ) The problem is that I'm still not sophisticated enough to understand how to pass the variable here. When I try to pass drawingname to the attribute value for the attribute "Drawing_Number", I don't get the concatenated string I'm expecting. It should be 100-"the file name", but I'm obviously doing something wrong in passing the variable. Obviously, the only thing that will happen is the value will literally become drawingname, not the value of the variable drawingname. If I remove the quotes from "drawingname", I get the error: bad DXF group (1 . DRAWING NAME). It's something very simple I can feel it. Edited August 28, 2015 by Da Ballz Quote Link to comment Share on other sites More sharing options...
BIGAL Posted August 28, 2015 Share Posted August 28, 2015 A slight suggestion rather than worry about deleting from selection set just scroll through all items. (if (setq ss (ssget "X" '((0 . "insert")(2 . "Drawing_Sheet_*,")))) (progn (setq x -1) (while (setq ent (ssname ss (setq x (+ x 1)))) ;my replacement code example (setq oldtag1 "Drawing_number") ;attribute tag name (foreach att (vlax-invoke (vlax-ename->vla-object (ssname SS x )) 'getattributes) (if (= oldtag1 (strcase (vla-get-tagstring att))) (vla-put-textstring att drawingname) ) ; end if ) Quote Link to comment Share on other sites More sharing options...
Da Ballz Posted August 28, 2015 Author Share Posted August 28, 2015 BIGAL Perfect, works like a charm. I like your visual lisp better than my ATT:REPLACE. Quote Link to comment Share on other sites More sharing options...
Tharwat Posted August 28, 2015 Share Posted August 28, 2015 (while (setq [color="blue"]ent [/color](ssname ss (setq x (+ x 1)))) (foreach att (vlax-invoke (vlax-ename->vla-object [color="red"](ssname SS x )[/color]) 'getattributes) Since that you already have the variable ent that obtains the entity name , so there is no need to re-retrieve the entity name once again Quote Link to comment Share on other sites More sharing options...
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.