Conversion problem

#1
Hello Everyone,

Okay, I admit that even though my lisp skills have improved greatly over the last several months even I know when to cry “uncle.” So I turn this over to the experts for your advise. This routine seems to be quite professionally written and may be quite useful when corrected.

There seems to be a conversion problem with the following lisp routine. It was originally designed for AutoCAD R12 & 14 I know that it also works in R2000. However there seems to be a problem running it in IntelliCAD 2000.

The program is intended to read all lines on specific layers and then labels their midpoints, with a specific block, with an attribute option for future editing and the length of the line. IntelliCAD seems to be having a problem labeling the length although I know, from history, that it is reading the length with no problem. This is causing the routine to cancel and all that shows up is the actual attribute default text in place of the true length.

I have a copy of the “pipetag” block that is used and a prototype drawing with the necessary layers already set up if anyone would like a copy of these please email me at melodie@etoolbox.com .

(defun c:tagall ()
(setq lnth "" len "" l1 "" l2 "" l3 "" pnt1 ""
pnt2 "" ang "" err "" midp "" ln1 "" ln2 "" ln3 ""
)
(command "dimzin" 1)
(setq oldlay (getvar "clayer"))
(command "layer" "s" "ccpipes" "")
(setq lines (ssget "x" '((0 . "LINE") (8 . "AFLOOP"))))
(setq mains (ssget "x" '((0 . "LINE") (8 . "MAINS"))))
(command "select" lines mains "")
(setq pipes (ssget "p"))
(setq num (sslength pipes))
(setq inc 0)
(while (< inc num)
(setq next (ssname pipes inc))
(setq ent (entget next))
(setq pnt1 (cdr (assoc 10 ent))
pnt2 (cdr (assoc 11 ent))
ang (angle pnt1 pnt2)
len (distance pnt1 pnt2)
midp (polar pnt1 ang (/ len 2))
ang (/ ang (/ pi 180))
)
(setq l1 (atoi (rtos len))
l2 (atoi (rtos (- len (* l1 12)) 2))
l3 (- len (atoi (rtos len 2)))
)
(if (< l3 0.50)
(setq ln3 "")
(setq l3 l3)
)
(if (>= l3 0.50)
(setq l2 (1+ l2)
ln3 ""
)

(setq l3 l3)
)
(if (= l2 12)
(setq l2 0
l1 (1+ l1)
)
(setq l2 l2)
)
(setq ln1 (itoa l1))
(setq ln2 (itoa l2))
(setq ln3 ln3)
(setq lnth (strcat ln1 "-" ln2 ln3))
(if (and (> ang 90) (< ang 271))
(setq ang (+ ang 180))
(setq ang ang)
)
(command "insert" "pipetag"
midp "" "" ang lnth "" "" "")
(setq inc (1+ inc))
);while
(command "layer" "s" oldlay "")
);tagall


Indentions not showing are my error, I thought the tabs would remain when I pasted.

I appreciate any help given.

Melodie


[This message has been edited by MTriche (edited 03-14-2001).]

#2
I believe you must provide the Z scale factor in the insert function:
(command "insert" "pipetag" midp "" "" "" ang lnth "" "" "")

Hope this helps.

[This message has been edited by avaernes (edited 03-14-2001).]

#3
Thank you Avaernes,

Here I was trying to tear apart and find an error in the guts of the routine and it turns out to be in the simple insert command. Don't I feel really silly!

This definitely solved the problem and I cannot express my appreciation enough.

Thank you again,

Melodie