Old routine not working for 2016 MEP

Old routine not working for 2016 MEP

robcomrie
Contributor Contributor
572 Views
5 Replies
Message 1 of 6

Old routine not working for 2016 MEP

robcomrie
Contributor
Contributor

Recently migrated to 2016 and the following bubble routine I'm not able to get working

 

(DEFUN bentcl ()

;;; To draw circle ;;;
(Defun MKCIRC ()
(Command "CIRCLE" gfpt2 gfrad1)
)
;;; To draw ellipse ;;;
(DeFun MKELL ()
(Command "ELLIPSE" "_C" gfpt2 gfpt3 gfpt6)
)
(Setq dimscl (GetVar "DIMSCALE")
gfsnp1 (GetVar "osmode")
gfth1 (GetVar "TEXTSIZE")
gfth2 (* 0.125 dimscl)
txtclr (getvar "DIMCLRT")
gflyr1 (GetVar "CLAYER")
gfrad1 (* 0.1875 dimscl)) ; <--Set bubble radius here
(SetVar "OSMODE" 1)
(Command "LAYER" "M" "GRIDMARKS" "C" txtclr "" "")
(Setq gfpt1 (GetPoint "\n Pick \"NEAR\" the END of the LINE you want bubble on :"))
(Princ "\n Previous Text Was ---> ") (Princ *GFTXT1*)
(SetVar "OSMODE" 0)
(Setq *GFTXT1* (GetString T "\n Enter New Text : ")
gflen1 (Strlen *GFTXT1*))
(PROMPT "\n Where do you want to draw the bubble?")
(STRD "\n (A)bove (L)eft (B)elow (R)ight" quad)
(Setq quad VAR);;; I figure it error here because STRD is not a Lisp command but can't figure how to rewrite it to get the keyword entry to set to "quad" ;;;
(IF (= quad (strcase "R")) (Setq gfang1 0.0))
(IF (= quad "A") (Setq gfang1 90))
(IF (= quad "L") (Setq gfang1 180))
(IF (= quad "B") (Setq gfang1 270))
(IF (= quad (strcase "R")) (Setq gfang2 90))
(IF (= quad "A") (Setq gfang2 0.0))
(IF (= quad "L") (Setq gfang2 90))
(IF (= quad "B") (Setq gfang2 0.0))
(IF (= quad (strcase "r")) (Setq gfang1 0.0))
(IF (= quad "a") (Setq gfang1 90))
(IF (= quad "l") (Setq gfang1 180))
(IF (= quad "b") (Setq gfang1 270))
(IF (= quad (strcase "r")) (Setq gfang2 90))
(IF (= quad "a") (Setq gfang2 0.0))
(IF (= quad "l") (Setq gfang2 90))
(IF (= quad "b") (Setq gfang2 0.0))
(Setq gfpt2 (Polar gfpt1 (DTR gfang1) (* 0.3125 dimscl)); <--Locate text insert here
gfpt3 (Polar gfpt1 (DTR gfang1) (* 0.125 dimscl))); <--Set length of Extension Line here
(Command "LINE" gfpt1 gfpt3 "")
(Command "TEXT" "_M" gfpt2 gfth2 gfang2 *GFTXT1*)
(Setq gfent1 (EntGet (EntLast))
gfpt4 (cdr (Assoc 10 gfent1))
gfpt5 (cdr (Assoc 11 gfent1))
gfdist1 (Distance gfpt4 gfpt5)
gfdist2 (* gfdist1 1.25)
gfpt6 (Polar gfpt2 (DTR gfang2) gfdist2))
(If (> gflen1 3) (MKELL) (MKCIRC))
;;; Reset System ;;;
(SetVar "OSMODE" gfsnp1)
(Setvar "TEXTSIZE" gfth1)
(SetVar "CLAYER" gflyr1)
(Princ)
)

0 Likes
Accepted solutions (1)
573 Views
5 Replies
Replies (5)
Message 2 of 6

ВeekeeCZ
Consultant
Consultant

Try to replace couple of lines:

 

Spoiler
(PROMPT "\n Where do you want to draw the bubble?")
(STRD "\n (A)bove (L)eft (B)elow (R)ight" quad)
(Setq quad VAR);;; I figure it error here because STRD is not a Lisp command but can't figure how to rewrite it to get the keyword entry to set to "quad" ;;;
(IF (= quad (strcase "R")) (Setq gfang1 0.0))
(IF (= quad "A") (Setq gfang1 90))
(IF (= quad "L") (Setq gfang1 180))
(IF (= quad "B") (Setq gfang1 270))
(IF (= quad (strcase "R")) (Setq gfang2 90))
(IF (= quad "A") (Setq gfang2 0.0))
(IF (= quad "L") (Setq gfang2 90))
(IF (= quad "B") (Setq gfang2 0.0))
(IF (= quad (strcase "r")) (Setq gfang1 0.0))
(IF (= quad "a") (Setq gfang1 90))
(IF (= quad "l") (Setq gfang1 180))
(IF (= quad "b") (Setq gfang1 270))
(IF (= quad (strcase "r")) (Setq gfang2 90))
(IF (= quad "a") (Setq gfang2 0.0))
(IF (= quad "l") (Setq gfang2 90))
(IF (= quad "b") (Setq gfang2 0.0))

  

 

 

with this:

Spoiler
(initget 1 "Above Left Below Right")
(setq quad (getkword "\nWhere do you want to draw the bubble? [Above/Left/Below/Right]: "))
(cond ((= quad "Above")
       (setq gfang1 90
	     gfang2 0))
      ((= quad "Left")
       (setq gfang1 180
	     gfang2 90))
      ((= quad "Below")
       (setq gfang1 270
	     gfang2 0))
      ((= quad "Right")
       (setq gfang1 0
	     gfang2 90)))

 

 

 

0 Likes
Message 3 of 6

marko_ribar
Advisor
Advisor

Remove red lines and replace them with :

 

(initget 1 "A a B b R r L l")
(setq quad (getkword "\n (A)bove (B)elow (R)ight (L)eft [A/B/R/L] : "))

Also add this subfunction :

(defun DTR ( a )
  (cvunit a "degree" "radian")
)

Or alternatively :

(defun DTR ( a )
  (* (/ a 180.0) pi)
)

HTH, M.R.

Marko Ribar, d.i.a. (graduated engineer of architecture)
0 Likes
Message 4 of 6

marko_ribar
Advisor
Advisor

Beekee beat me... ha,ha,ha...

 

Make sure you localize your variables - look into starting statement (defun ... )

Here is useful link :

http://www.lee-mac.com/localising.html

 

M.R.

Marko Ribar, d.i.a. (graduated engineer of architecture)
Message 5 of 6

ВeekeeCZ
Consultant
Consultant
Accepted solution

In addition what have been said by Marco...

 

(Command "LAYER" "M" "GRIDMARKS" "C" txtclr "" "")  ; this line fails if dimclrt = 0

 

 

 

You can use this to fix it:

 

  (Command "LAYER" "M" "GRIDMARKS")
   (if (/= txtclr 0) (command "C" txtclr ""))
  (command "") 

 

Message 6 of 6

robcomrie
Contributor
Contributor
Thanks...works like a charm
0 Likes