Jump to content

Saveas Directory using attribute Value


Halb10

Recommended Posts

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.

Link to comment
Share on other sites

(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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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)
)

Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...