lisp routine will work on 1 computer but not the next???

Hi,

We have 5 workstations all running WIN XP and BricsCad V11 and don't seem to be having any other problems except for this one Lisp file.

The Lisp file we use to develop cones within autocad works fine on one of the Workstations but when we try and run it on any other it will only draw the inside and outside circles and won't trim away and leave the Cone Development. Can't work out why it would run flawlessly on one computer and not any others...we all run the same version of BricsCad.

Help!!!!!

; Convert angle in degrees to radians
(defun dtr (a)
(* pi(/ a 180.0))
)
; Configs Cones & Draws it in the flat
(defun c:cd ()
(setvar "lunits" 2)
(setvar "luprec" 2)
(SETQ DZIN (getvar "dimzin"))
(SETQ PCK1 (Getpoint "\nPick Location of Cone: "))
(setq DZIN (getvar "dimzin"))
(SETQ LD (GETREAL "\nEnter Large ID: "))
(SETQ SD (GETREAL "\nEnter Small ID: "))
(SETQ H (GETREAL "\nEnter Mean Height of Cone: "))
(SETQ THK (GETREAL "\nEnter Thickness: "))
(SETQ qqq (GETREAL "\nEnter how many segments: "))
(setq HH (getint "\ text H: 2 to 20 "))
(setvar"textsize" HH)
(setq D (+ LD THK))
(setq D1 (+ SD THK))
(setq 2b (- D D1))
(setq b (/ 2b 2))
(setq sqh (* h h))
(setq sqb (* b b))
(setq sqrc (+ sqb sqh))
(setq c (sqrt sqrc))
(setq r (/ D 2))
(setq R2 (/ (* c r) b))
(setq e (- R2 c))
(setq deg (* (/ r R2) 360))
(setq deg (/ deg qqq))
(setq lim (* R2 2))
(setq limi (+ lim 20))
(command "circle" PCK1 e)
(command "circle" PCK1 R2)
(setq Ptt2 (polar PCK1 (dtr 0.0) R2))
(setq Ptt3 (polar PCK1 (dtr 0.0) e))
(command "line" Ptt2 Ptt3 "")
(command "line" Ptt2 Ptt3 "")
(command "zoom" "c" PCK1 limi "")
(command "rotate" "l" "" PCK1 deg)
(setq Ptt4 (polar PCK1 (dtr 359.9) (+ r2 100.0)))
(command "trim" "" "f" PCK1 Ptt4 "" "")

(setq LD (strcat "Large diameter ID : " (rtos LD 2 1) " mm"))
(setq SD (strcat "Small diameter ID : " (rtos SD 2 1) " mm"))
(setq H (strcat "Heigth VH : " (rtos H 2 1) " mm"))
(setq THK (strcat "Thickness : " (rtos THK 2 1) " mm"))
(setq QQQ (strcat "how many segments required : " (rtos QQQ 2 1)))



; Place text:
(setq ins (getpoint "\nPick Text Location: "))

(command "mtext" ins "j" "MC" ins LD SD H thk qqq "")
)

Cheers

Doug

Comments

  • Probably an osmode problem. Depending on osmode and zoom I get unpredictable results. Try setting osmode to 0 before using any commands in the lisp.

  • I would consider screen resolution instead. A lower screen resolution means there are less pixels for the application and less pixels forthe drawing window.

    Relatively to the entities, the pickbox is then larger and less discriminating, leading to odd failures.

  • Thanks Roy,

    Works now.....still have a litle bit of tweeking to do as it brings the help screen up now before you can insert the text and it only works once per drawing.

    Is there something we need to add to get it to do multipul cone developments per drawing?

    Cheers

     

  • Salve Caesar ;)

    In the line

    (command "zoom" "c" PCK1 limi "")

    remove the last "". It should be

    (command "_.zoom" "_c" PCK1 limi)

    Then I guess it should work.

    Regards, Stephan

  • Why not draw an arc instead of a circle that you then trim:

    (defun c:cd ( / B C DEG H LD LR LRFLAT oldDimzin oldOsmode PT SD SEGM SRFLAT THK)
    (setq oldDimzin (getvar "dimzin"))
    (setq oldOsmode (getvar "osmode"))
    (setq PT (getpoint "\nPick Location of Cone: "))
    (setq LD (getreal "\nEnter Large ID: "))
    (setq SD (getreal "\nEnter Small ID: "))
    (setq H (getreal "\nEnter Mean Height of Cone: "))
    (setq THK (getreal "\nEnter Thickness: "))
    (setq SEGM (getreal "\nEnter number of segments: "))
    (setq B (/ (- LD SD) 2))
    (setq C (sqrt (+ (* B B) (* H H))))
    (setq LR (/ (+ LD THK) 2))
    (setq LRFLAT (* (/ C B) LR))
    (setq SRFLAT (- LRFLAT C))
    (setq DEG (/ (* (/ LR LRFLAT) 360) SEGM))
    (setvar "cmdecho" 0)
    (setvar "osmode" 0)
    (command
    "_.arc" "c" PT (polar PT 0 LRFLAT) "a" DEG
    "_.arc" "c" PT (polar PT 0 SRFLAT) "a" DEG
    "_.line" (polar PT 0 SRFLAT) (polar PT 0 LRFLAT) ""
    "_.line" (polar PT (dtr DEG) SRFLAT) (polar PT (dtr DEG) LRFLAT) ""
    )
    (setvar "osmode" oldOsmode)
    (setq INS (getpoint "\nPick Text Location: "))
    (setvar "textsize" (getint "\nEnter text height 2 to 20: "))
    (setvar "dimzin" 0)
    (setvar "osmode" 0)
    (command
    "_.mtext" INS "j" "mc" INS
    (strcat "Large diameter ID : " (rtos LD 2 1) " mm")
    (strcat "Small diameter ID : " (rtos SD 2 1) " mm")
    (strcat "Height VH : " (rtos H 2 1) " mm")
    (strcat "Thickness : " (rtos THK 2 1) " mm")
    (strcat "Number of segments required : " (rtos SEGM 2 0))
    ""
    )
    (setvar "cmdecho" 1)
    (setvar "dimzin" oldDimzin)
    (setvar "osmode" oldOsmode)
    (princ)
    )
  • Thanks Steve, Thanks Roy,

    That did the trick mate......all sorted now...

    Cheers,

This discussion has been closed.