@Homecad2007 ,
How do I search and force units to be millimetres
^^^ Use the INSUNITS variable and set it to 4 (or just make sure your template has it set to Millimeters).
(setvar 'INSUNITS 4)
For the other routines such as Interp as shown in the image attached. I try to select 1 attribute and then another and the error I receive is bad function.
^^^ The "bad function" error is most likely because a parenthesis was incorrectly used OR because a predefined symbol was redefined to a real number. You can duplicate the error like so:
(setq ang 45.9774)
(ang 3.14)
Try running this version of your function.. I only did 3 things:
- Declared local variables (Please start doing this, it is a necessary practice)
- Added spaces after function names / between parenthesis
- Moved 1 closing parenthesis [on your second (if (and (< INTP2X INTP1X) ..... statement]. It seemed incorrect.
Let me know if it works.
(defun c:interp ( / ostemp cnt tbdata intpt1 intpt1a intpt1x intpt2 intpt2a intpt2x newpt dist aa dist1 ang dist2 percent newelev elev dim txtht txtht1)
(SETVAR "ATTREQ" 1)
(SETVAR "ATTDIA" 0)
(setvar "cmdecho" 0)
(setvar "blipmode" 0)
(setq ostemp (getvar "osmode"))
(command "osnap" "node")
(setq cnt 0)
(prompt "\nPick first elevation : ")
(SETQ tbdata (entget (car (entsel))))
(setq INTPT1 (dxf 10 tbdata));GETS POINT
(setq INTPT1A (entget (entnext (dxf -1 tbdata))))
(setq INTP1X (atof (dxf 1 INTPT1A)));GETS STRING
(prompt "\nPick second elevation : ")
(SETQ tbdata (entget (car (entsel))))
(setq INTPT2 (dxf 10 tbdata));GETS POINT
(setq INTPT2A (entget (entnext (dxf -1 tbdata))))
(setq INTP2X (atof (dxf 1 INTPT2A)));GETS STRING
(SETVAR "OSMODE" 545)
(setq newpt (osnap (getpoint "\npick point for new elevation: ") "nea"))
(setvar "osmode" 0)
(setq dist (distance INTPT1 INTPT2))
(setq aa (angle INTPT1 INTPT2))
(setq dist1 (/ (distance INTPT1 INTPT2) 2))
(IF (< INTP1X INTP2X) (setq ang (ANGTOS (angle INTPT1 INTPT2))))
(IF (> INTP1X INTP2X) (setq ang (ANGTOS (angle INTPT1 INTPT2))))
(setq dist2 0)
(setq percent (/ (abs (- INTP1X INTP2X)) dist));slope percentage
(if (and (< INTP1X INTP2X) (/= dist2 nil)) (setq dist2 (distance INTPT1 newpt)) (setq newelev (* percent dist2)))
(if (and (< INTP2X INTP1X) (/= dist2 nil)) (setq dist2 (distance INTPT2 newpt)) (setq newelev (* percent dist2)))
(if (< INTP1X INTP2X) (setq elev (rtos(+ INTP1X newelev) 2 2)))
(if (< INTP2X INTP1X) (setq elev (rtos(+ INTP2X newelev) 2 2)))
(setq dim (getvar "dimscale"));;new
(Setq txtht (* dim 10));;new
(Setq txtht1 (* dim 10));;new
;;(command "insert" "level" newpt "" "" ang elev )
(command "insert" "level" newpt txtht "" ang elev )
(if (or (> (car INTPT1) (car INTPT2))
(= (rtd aa) 270))
(command "rotate" "last" "" newpt 180.0)
);if
(setvar "cmdecho" 1)
(SETVAR "ATTDIA" 1)
(setvar "osmode" ostemp)
(princ)
)
Best,
~DD