+ Reply to Thread
Results 1 to 6 of 6
  1. #1
    Junior Member
    Computer Details
    Halb10's Computer Details
    Operating System:
    Windows 7
    Discipline
    Construction
    Using
    AutoCAD 2018
    Join Date
    Jan 2018
    Posts
    12

    Question Saveas Directory using attribute Value

    Registered forum members do not see this ad.

    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.

  2. #2
    Junior Member
    Computer Details
    Halb10's Computer Details
    Operating System:
    Windows 7
    Discipline
    Construction
    Using
    AutoCAD 2018
    Join Date
    Jan 2018
    Posts
    12

    Default

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

  3. #3
    Super Member rlx's Avatar
    Computer Details
    rlx's Computer Details
    Operating System:
    W10
    Computer:
    i74ghz/ssd500/2tbhdd
    Discipline
    Electrical
    rlx's Discipline Details
    Occupation
    electrical designer dragon
    Discipline
    Electrical
    Details
    I dont excel in anything but I rearly give up
    Using
    AutoCAD 2016
    Join Date
    Nov 2014
    Location
    Bergen op Zoom , Netherlands
    Posts
    758

    Default

    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.

    Code:
     (getfiled "testje" "d:\\temp\\lisp" "dwg" 0)
    is not the same as
    Code:
     (getfiled "testje" "d:\\temp\\lisp\\" "dwg" 0)
    (with the \\ at the end

    gr. Rlx

  4. #4
    Junior Member
    Computer Details
    Halb10's Computer Details
    Operating System:
    Windows 7
    Discipline
    Construction
    Using
    AutoCAD 2018
    Join Date
    Jan 2018
    Posts
    12

    Default

    Ok, so something like this

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

  5. #5
    Super Member rlx's Avatar
    Computer Details
    rlx's Computer Details
    Operating System:
    W10
    Computer:
    i74ghz/ssd500/2tbhdd
    Discipline
    Electrical
    rlx's Discipline Details
    Occupation
    electrical designer dragon
    Discipline
    Electrical
    Details
    I dont excel in anything but I rearly give up
    Using
    AutoCAD 2016
    Join Date
    Nov 2014
    Location
    Bergen op Zoom , Netherlands
    Posts
    758

    Default

    untested :


    Code:
    (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)
    )

  6. #6
    Junior Member
    Computer Details
    Halb10's Computer Details
    Operating System:
    Windows 7
    Discipline
    Construction
    Using
    AutoCAD 2018
    Join Date
    Jan 2018
    Posts
    12

    Default

    Registered forum members do not see this ad.

    That works fine. Exactly what I needed.

    Thank you rlx

Similar Threads

  1. SAVEAS... a file with an ammended name, derived from an ATTRIBUTE value...
    By lamensterms in forum AutoLISP, Visual LISP & DCL
    Replies: 4
    Last Post: 11th Jul 2013, 01:46 am
  2. Sa - saveas??
    By ILoveMadoka in forum AutoCAD 2D Drafting, Object Properties & Interface
    Replies: 4
    Last Post: 11th Apr 2011, 01:31 pm
  3. saveas- how to use?
    By muthu123 in forum AutoLISP, Visual LISP & DCL
    Replies: 3
    Last Post: 15th Jul 2010, 12:42 pm
  4. SaveAs New Name
    By chomuth in forum AutoLISP, Visual LISP & DCL
    Replies: 4
    Last Post: 17th Feb 2010, 06:14 pm
  5. Saveas
    By FazBear in forum AutoLISP, Visual LISP & DCL
    Replies: 1
    Last Post: 30th May 2009, 12:07 pm

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts