Script file Help (text styles and file saving)

Discussion in 'AutoCAD' started by Cory McConnell, Apr 2, 2004.

  1. 1) I would like to change all the text styles in the dwg to a textstyle that
    is in my template. I don't have any idea where to begin.

    3) I have a script coping and pasting everything from mspace into a new
    file. After this happens, I would like to close the original file, and
    overwrte it with the new one (with the same name as the first). I am at a
    loss here as well.
     
    Cory McConnell, Apr 2, 2004
    #1
  2. Cory McConnell

    zeha Guest

    ; before close the original file

    (if (setq f (open "c:\\dwgname.txt" "w"))
    (progn (write-line (strcat (getvar "dwgprefix")(Getvar "dwgname")) f)(close f))
    )
    ; then in the new file

    (if (and (setq f (open "c:\\dwgname.txt" "r"))
    (progn (setq dwgnm (read-line f))(close f)
    (if dwgnm (command ".saveas" dwgnm "yes"))
    )
    )

    ; hope this helps
     
    zeha, Apr 5, 2004
    #2
  3. Question from somebody that knows nothing of Lisp: How can I assign a
    command name to these code snippets?
     
    Cory McConnell, Apr 5, 2004
    #3
  4. Cory McConnell

    zeha Guest

    you can do it in a script file or you can make a function that can called from the command line

    example

    make a file (with notepad or wordpad or within autocad vlisp)filename setname.lsp

    put the next code in the file
    (defun c:setname (/ dwgnm)
    (setq dwgnm (strcat (getvar "dwgprefix")(getvar "dwgname")))
    (vl-propagate 'dwgnm)
    )

    save the code
    put the file in the searchpath of Autocad
    and then load the file
    (load"setname")

    on the command line just type setname and ENTER
    the variable dwgnm is now available in all the drawings opened in the same session

    try it

    go to the next drawing where you pasted the copied entities
    type !dwgnm

    and so you see the variable is set to the dwgname where you give the command setname
    setname is the function that you created (in the setname.lsp)

    good luck
     
    zeha, Apr 6, 2004
    #4
  5. Thanks - I will givw it a whirl...
     
    Cory McConnell, Apr 7, 2004
    #5
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.