Lisp No Longer Works in 2005 - Please Help

Discussion in 'AutoCAD' started by Sam Manzella, Jun 28, 2004.

  1. Sam Manzella

    Sam Manzella Guest

    Hi, when I execute the "V" options for vanes, the lisp should insert a vanes
    block, and keep on going. However, the routine now asks for the rotation
    angle, and the routine gets broken. In 2002, the routine would pick the
    rotation according to the next point you'd select on the screen. I can't
    figure out how to fix it. Below is the routine. If it helps, I can send a
    certain size turning Vane block to be put in a search path.

    Thank you. Sam

    ----------------------------------------------------------------------------
    -----------

    (defun UDIST (bit kwd msg def bpt / inp)
    (if def
    (setq msg (strcat "\n" msg "<" (rtos def) ">: ")
    bit (* 2 (fix (/ bit 2))))
    (if (= " " (substr msg (strlen msg) 1))
    (setq msg (strcat "\n" (substr msg 1 (1- (strlen msg))) ": "))
    (setq msg (strcat "\n" msg ": "))
    )
    )
    (initget bit kwd)
    (setq inp (if bpt
    (getdist msg bpt)
    (getdist msg)
    ))
    (if inp
    inp
    def
    )
    )
    ;end defun udist
    (defun UPOINT (bit kwd msg def bpt / inp)
    (if def
    (setq pts (strcat (rtos (car def)) "," (rtos (cadr def)))
    msg (strcat "\n" msg "<" pts ">: ")
    bit (* 2 (fix (/ bit 2))))
    (if (= " " (substr msg (strlen msg) 1))
    (setq msg (strcat "\n" (substr msg 1 (1- (strlen msg))) ": "))
    (setq msg (strcat "\n" msg ": "))
    )
    )
    (initget bit kwd)
    (setq inp (if bpt
    (getpoint msg bpt)
    (getpoint msg)
    ))
    (if inp
    inp
    def
    )
    )
    ;end defun upoint
    (defun KERR (x)
    (if (/= "Function cancelled")
    (princ (strcat "\nError: " x))
    )
    (setq *error* olderr)
    (command "LAYER" "S" #lay "")
    (setvar "PICKBOX" #pick)
    (setvar "OSMODE" #osnap)
    (setvar "FILLETRAD" #rad)
    (prin1)
    )
    ;end defun kerr
    (defun c:sduct2 (/ inp num ang1 ang2 pt1 pt1a pt1b pt2a pt2b pt3a pt3b rad1
    rad2
    dist1 dist2 pp1 pp2 pp3 pp4 inspt1 inspt2 inspt3 inspt4
    pp1
    pp2 pp3 pp4 owid ttab inpang inpblk
    )
    (setq olderr *error*
    *error* kerr
    #lay (getvar "CLAYER")
    #osnap (getvar "OSMODE")
    #pick (getvar "PICKBOX")
    #rad (getvar "FILLETRAD"))
    (setq pl1 "M-HVAC-SDCT")
    (command "LAYER" "S" pl1 "")
    (setq #pt2 (UPOINT 1 " " "Start point" #pt2 nil)
    #wid (UDIST 5 " " "Duct width" #wid nil)
    ang2 nil
    owid #wid)
    (while (setq pt1 (UPOINT 0 "Trans Rtran Ltran Vanes"
    "Trans/Rtran/Ltran/Vanes/Next point or Return to
    quit"
    nil #pt2
    ))
    (cond
    ((= pt1 "Trans") (setq ttab 1.0))
    ((= pt1 "Rtran") (setq ttab 0.6))
    ((= pt1 "Ltran") (setq ttab 0.0))
    ((= pt1 "Vanes") (setq rad1 0.0
    ttab nil)
    )
    ((listp pt1) (setq rad1 1.0
    ttab nil)
    )
    )
    (cond
    ((= (type pt1) 'STR) (setq pt1 (UPOINT 1 " " "Next point" nil #pt2)))
    )
    (while (and (setq ang1 (angle #pt2 pt1)
    ang2 (if (null ang2)
    ang1
    ang2
    )
    ang1 (if ttab
    ang2
    ang1
    )
    rad1 (if (= ang1 ang2)
    nil
    rad1
    )
    theta (/ (min (abs (- ang1 ang2)) (- (* pi 2.0)
    (abs (- ang1
    ang2))
    )
    ) 2.0
    )
    pt2a (polar #pt2 (+ ang1 (/ pi 2.0)) (/ owid 2.0))
    pt2b (polar pt2a (- ang1 (/ pi 2.0)) owid))
    (> theta (/ pi 4.0))
    )
    (setq pt1 (UPOINT 1 " "
    "Duct bends need to be 90 degrees or less.\nNext
    point" nil
    #pt2
    ))
    )
    (setvar "OSMODE" 0)
    (setvar "PICKBOX" 0)
    (cond
    (ttab
    (progn
    (setq #wid (UDIST 5 " " "New width" #wid nil)
    pt3a pt2a
    pt3b pt2b
    num (* (/ (- #wid owid) (+ 1.0 (* 1.0 (float (fix
    ttab)))))
    (atof (rtos ttab 2 0))
    )
    inp (min (distance pt1 #pt2) (max (/ (+ #wid owid) 2.0)
    (* (sqrt 3.0) (abs
    num))
    )
    )
    pt2a (polar (polar pt3a ang1 inp) (+ ang1 (/ pi 2.0))
    num)
    pt2b (polar pt2a (- ang1 (/ pi 2.0)) #wid)
    #pt2 (polar pt2a (- ang1 (/ pi 2.0)) (/ #wid 2.0))
    owid #wid)
    (command "LINE" pt3a pt3b pt2b pt2a "C")
    )
    )
    )
    (setq dist1 (max (distance pt1 #pt2) (+ (* (/ #wid 2.0) (+ 1.0 (/
    (sin
    theta)
    (cos
    theta)
    )
    )
    ) 3.0
    )
    )
    pt1 (polar #pt2 ang1 dist1)
    pt1a (polar pt2a ang1 dist1)
    pt1b (polar pt2b ang1 dist1)
    inspt1 pt2a
    inspt2 pt2b)
    (command "LINE" pt2a pt1a "")
    (command "LINE" pt2b pt1b "")
    (cond
    (rad1 (setq inpang (rem (/ (+ (* (if (> ang1 ang2)
    -1.0
    1.0
    ) pi
    ) ang1 ang2
    ) 2.0
    )
    (* pi 2.0)
    )
    inspt1 (polar #pt2 (+ pi inpang) (/ #wid (* 2.0 (cos
    theta))))
    inspt2 (polar inspt1 inpang (/ #wid (cos theta)))
    theta (/ (sin theta) (cos theta))
    rad1 (* rad1 (min (- (/ (- dist2 3.0) theta) (/ #wid 2.0))
    (/ (- dist1 (* theta #wid) 3.0) 2.0)
    #wid
    )
    )
    rad2 (if (zerop rad1)
    0.0
    (+ rad1 #wid)
    )
    dist1 (- dist1 (* theta (+ (/ #wid 2.0) rad1)))
    inp (if (equal (angle inspt3 inspt1) ang2 0.001)
    inspt3
    inspt4
    ))
    (if (= (rtos (angle inspt1 pt3b) 2 3) (rtos ang2 2 3))
    (setq pp1 pt1b
    pp2 pt2a
    pp3 pt3a
    pp4 pt3b)
    (setq pp1 pt1a
    pp2 pt2b
    pp3 pt3b
    pp4 pt3a)
    )
    (command "ERASE" (ssget pp4) "")
    (command "LINE" inp inspt1 "")
    (setvar "FILLETRAD" rad1)
    (command "FILLET" (entlast) (ssget pp1))
    (setvar "FILLETRAD" rad2)
    (command "FILLET" (ssget pp2) (ssget pp3))
    (if (zerop rad2)
    (if (and (> (distance inspt1 inspt2) 13.44)
    (< (distance inspt1 inspt2) 113.84)
    )
    (progn
    (setq inpblk (strcat (rtos (* 2.0 (atof (rtos (/ (*
    (cos

    (/ pi 4.0)
    )

    (distance inspt1 inspt2)
    ) 2.0
    ) 2 0
    )
    )
    ) 2 0
    ) "TURN"
    ))
    (command "INSERT" inpblk inspt1 1.0 "" (+ (cvunit inpang
    "radians"
    " degrees"
    ) 135.0
    )
    )
    )
    )
    (progn
    (setq pt3a (polar inspt1 (+ pi ang2) (* theta rad1))
    pt3b (polar inspt2 (+ pi ang2) (* theta rad2))
    pt2a (polar inspt1 ang1 (* theta rad1))
    pt2b (polar inspt2 ang1 (* theta rad2))
    inspt1 pt2a
    inspt2 pt2b)
    (command "LINE" pt3a pt3b "")
    (command "LINE" pt2a pt2b "")
    )
    )
    )
    )
    (setq inspt3 inspt1
    inspt4 inspt2
    ang2 ang1
    dist2 dist1
    #pt2 pt1
    pt3a pt1a
    pt3b pt1b)
    (setvar "PICKBOX" #pick)
    (setvar "OSMODE" #OSNAP)
    ) ;while
    (command "LAYER" "S" #lay "")
    (setvar "FILLETRAD" #rad)
    (setq *error* olderr)
    (gc)
    (princ)
    )
     
    Sam Manzella, Jun 28, 2004
    #1
  2. Sam Manzella

    Jim Claypool Guest

    The problem must be with the cvunit function that you did not include. Are
    you sure you are defining it in 2005?
     
    Jim Claypool, Jun 28, 2004
    #2
  3. Sam Manzella

    Sam Manzella Guest

    Hi Jim,

    Thanks for the reply. I'm really not sure how I would specifically define
    that in 2005. Isn't it defined below, right after the "INSERT" command?

    Thank you,
    Sam
     
    Sam Manzella, Jun 29, 2004
    #3
  4. Sam Manzella

    ECCAD Guest

    From Help, AutoLisp..
    "The acad.unt file defines various conversions between real-world units such as miles to kilometers, Fahrenheit to Celsius, and so on. The function cvunit takes a value expressed in one system of units and returns the equivalent value in another system. The two systems of units are specified by strings containing expressions of units defined in acad.unt. "

    cvunit is a defined function. There must be something else wrong.

    Bob
     
    ECCAD, Jun 29, 2004
    #4
  5. Just some wild guesses after looking at the code, probably nothing to do
    with the problem, but.... in the call to cvunit the " degrees" has a space
    in front of it. Probably nothing, but Autodesk made other changes for speed
    that broke existing applications, and removing a ltrim from that function
    would speed it up. Verify that your acad.unt file has degree and radian
    conversion in it. Also you may want to turn on the cmdecho variable so you
    can see the program running the commands and see if one of them are failing
    before it gets to the insert command. I would suspect the fillet commands,
    they dont seem to be called with the appropriate parameters. I have seen
    this work, but it is not always guarenteed. Also look at the new settings
    for the fillet command, they may be having some effect on the results that
    causes on of the other commands to fail.
     
    Randy Sanders, Jun 29, 2004
    #5
  6. Sam Manzella

    ECCAD Guest

    Try:
    (command "-insert" inpblk inspt1 1.0 "" (+ (cvunit inpang
    "radians" "degrees")

    And, check variable inpang to be set to a value..probably 0.0

    Bob
     
    ECCAD, Jun 29, 2004
    #6
  7. Sam Manzella

    Sam Manzella Guest

    Thanks guys. I'll have to test your suggestions next Tuesday. I've been out
    of the office all day today, and I'll be on vacation for the rest of the
    week. (I don't have 2005 on my laptop, otherwise I'd be trying the
    suggestions out right now). Anyway, I logged on to this newsgroup to check
    this message and see if anyone has replied, and also to make sure I'm not
    coming across as rude not thanking you for the suggestions until next week.

    I'll let you know how it goes.

    Thanks again,
    Sam
     
    Sam Manzella, Jun 30, 2004
    #7
  8. Sam Manzella

    Sam Manzella Guest

    Ok, you guys mentioned the acad.unt file and that gave me some grounds to
    work with. Turns out that I didn't have a search path to the
    "..\UserDataCache\Support" folder, which is where that file is located in
    this version. These new UserDataCache and Roaming Profile folders are really
    throwing me in for a loop!!

    Thanks again for the help.
    Sam

    ----------------------


     
    Sam Manzella, Jul 7, 2004
    #8
  9. Sam,

    You should *not* be adding UserDataCache to the search path.

    Files in that folder are automatically copied to the user's profile support
    folder upon installation, and that is the folder that should be in the
    support path. I verified that Acad.unt is in the user's profile folder.


    --
    R. Robert Bell


    Ok, you guys mentioned the acad.unt file and that gave me some grounds to
    work with. Turns out that I didn't have a search path to the
    "..\UserDataCache\Support" folder, which is where that file is located in
    this version. These new UserDataCache and Roaming Profile folders are really
    throwing me in for a loop!!

    Thanks again for the help.
    Sam

    ----------------------


     
    R. Robert Bell, Jul 7, 2004
    #9
  10. Sam Manzella

    Sam Manzella Guest

    Thanks Robert. I fixed it. I noticed that I have the acad.unt file in the
    roaming profile as well. Now, I've really cleaned up my mess. I basically
    have my Acad.lsp setting the search paths at startup, and I had it setting
    up this "C:\Documents and Settings\SJM\Application Data\Autodesk\AutoCAD
    2004\R16.0\enu\Support", where it should have been setting up this:
    "C:\Documents and Settings\SJM\Application Data\Autodesk\AutoCAD
    2005\R16.1\enu\Support"

    I carried over the Acad.lsp from when I was configuring 2004, and I missed
    that little detail there...

    It's all working as it should.

    Thanks again for the reply.
    Sam
     
    Sam Manzella, Jul 7, 2004
    #10
  11. Sam Manzella

    Sam Manzella Guest

    Thanks Robert. I fixed it. I noticed that I have the acad.unt file in the
    roaming profile as well. Now, I've really cleaned up my mess. I basically
    have my Acad.lsp setting the search paths at startup, and I had it setting
    up this "C:\\Documents and Settings\\%username%\\Application
    Data\\Autodesk\AutoCAD
    2004\\R16.0\\enu\\Support", where it should have been setting up this:
    "C:\\Documents and Settings\\%username%\\Application Data\\Autodesk\\AutoCAD
    2005\\R16.1\\enu\Support"

    I carried over the Acad.lsp from when I was configuring 2004, and I missed
    that little detail there...

    It's all working as it should.

    Thanks again for the reply.
    Sam
     
    Sam Manzella, Jul 7, 2004
    #11
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.