Halb10 Posted February 14, 2018 Posted February 14, 2018 Hi, is there a way to save my drawing with its name in a directory by using a Attribute value. Example: Drawingname: test.dwg blockname: TitleBlock Attribute: SF:WE Attribute-Value: test2 And it should save the drawing in: C:drawing/test drawing/(attribute-value)/... but it should be in a dialogbox, so i can choose the specific subfolder the direcotry up to the attribute-value is fix. Quote
Halb10 Posted February 14, 2018 Author Posted February 14, 2018 (defun c:FOO (/ LM:GetAttributeValue ss attValue) (setvar "filedia" 0) (defun LM:GetAttributeValue (blk tag / val enx) (while (and (null val) (= "ATTRIB" (cdr (assoc 0 (setq enx (entget (setq blk (entnext blk)))))) ) ) (if (= (strcase tag) (strcase (cdr (assoc 2 enx)))) (setq val (cdr (assoc 1 enx))) ) ) ) (if (and (setq ss (ssget "X" '((0 . "INSERT") (2 . "TitleBlock") (66 . 1)))) (setq attValue (LM:GetAttributeValue (ssname ss 0) "SF:WE")) ) (command "_saveas" "_2007" (getfiled "Speichern" (strcat "C:\\drawing\\test drawing\\(*****)" (vl-filename-base (getvar "dwgname"))) "dwg" 1) ) ;(prompt (strcat "\n[Attribute Value] : " attValue)) ) (princ) (setvar "filedia" 1) ) got this Code. But I can't get it to work. (*****) there should be attValue. Quote
rlx Posted February 14, 2018 Posted February 14, 2018 A couple of things , firstly , I would place the getfiled outside the command function because all error checking has to be done before you run this. Secondly , are you certain this folder always exists? Also you would need an additional "\\" between (****) and the (vl-filename-base (getvar "dwgname")) and another at the end of this same expression. (getfiled "testje" "d:\\temp\\lisp" "dwg" 0) is not the same as (getfiled "testje" "d:\\temp\\lisp\\" "dwg" 0) (with the \\ at the end gr. Rlx Quote
Halb10 Posted February 15, 2018 Author Posted February 15, 2018 Ok, so something like this (command "_saveas" "2007") (getfiled "Speichern" (strcat C:\\drawing\\test drawing\\(attValue)\\" (vl-filename-base (getvar "dwgname"))) "dwg" 0) Yes, the folder exists. Is it possible with this kind of code to do this? Because I don't know how to get the Attribute Value in the Directory. Quote
rlx Posted February 15, 2018 Posted February 15, 2018 untested : (defun c:FOO (/ LM:GetAttributeValue ss attValue fol fn) (vl-load-com)(setvar "filedia" 0) (defun LM:GetAttributeValue (blk tag / val enx) (while (and (null val) (= "ATTRIB" (cdr (assoc 0 (setq enx (entget (setq blk (entnext blk)))))))) (if (= (strcase tag) (strcase (cdr (assoc 2 enx)))) (setq val (cdr (assoc 1 enx)))))) (if (and (setq ss (ssget "X" '((0 . "INSERT") (2 . "TitleBlock") (66 . 1)))) (setq attValue (LM:GetAttributeValue (ssname ss 0) "SF:WE")) (vl-file-directory-p (setq fol (strcat "C:\\drawing\\test drawing\\" attValue))) (setq fn (getfiled "Speichern" (strcat fol "\\" (vl-filename-base (getvar "dwgname"))) "dwg" 1)) ) (command "_saveas" "_2007" fn) ) (setvar "filedia" 1) (princ) ) Quote
Halb10 Posted February 15, 2018 Author Posted February 15, 2018 That works fine. Exactly what I needed. Thank you rlx 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.