"Z" coordinate
My attribute counting lisp stopped working in one file and I discovered all the blocks it works on had moved to a 'higher plane'.
The 2d drawing is about as high (Z-wise) as it is wide.
My blocks have never been anywhere but Z=0, but other groups of entities in the same (foreign-source) file are also at various Z's - grouped as a result of one of each copied around.
Maybe parts were drawn at various elevations, my blocks weren't. Perhaps osnap attached one accidentally to a non-Z entity.
To me the attribute counter should work regardless, but am I missing some setting or made some mistake drawing in 2d?
Flatten.. didn't. I had to change the Z of each type of entity group using the Properties dialogue.
Comments
-
My attribute counting lisp stopped working in one file and I discovered all the blocks it works on had moved to a 'higher plane'.
Are you saying that your Lisp skipped all entities with z=0. Or do you mean the opposite?0 -
Opposite. It normally counts every one, but in this case with around 100 blocks it only actually got one and then stopped.
It writes a separate piece of text on screen for block name then each of its attributes, before doing the same for the next block on a new line.
I just moved everything to Z=0 and continued work on the file in V11, which I keep coming back to.
[code](DEFUN C:COUNT (/ oldl oldp act1 b num act2 upd lst a n ss exp)
(SETQ OS (GETVAR "OSMODE"))
(SETVAR "OSMODE" 0)
(if (/= 0 (cdr (assoc 40 (tblsearch "style" (getvar "textstyle")))))
(progn
(princ "\nTextsize must be 0 ")(terpri))
(progn
(setq oldl (getvar "clayer"))
(COMMAND "LAYER" "M" "DEFPOINTS" "")
(SETQ OLDP (GETVAR "LUPREC"))
(SETVAR "LUPREC" 0)
(Defun act1 ()
(while (/= num (sslength ss))
(setq b (ssname ss num))
(if (= (cdr (assoc 1 (entget a)))
(cdr (assoc 1 (entget b))))
(progn (setq n (+ 1 n))
(ssdel b ss)(setq num (- num 1))))
(setq num (1+ num)))
)
(defun act2 ()
(setq upd (STRCAT (cdr (assoc 1 (entget a))) " " (rtos n)))
(SETQ LST (APPEND LST (LIST UPD)))
(ssdel a ss)(setq a (ssname ss 0))
(setq num 1)(setq n 1)
)
(SETQ LST NIL)
(setq ss (ssget))
(setq a (ssname ss 0))
(setq num 1)
(setq n 1)
(while (/= 0 (sslength ss))(act1)(act2))
(SETQ LST (ACAD_STRLSORT LST))
(SETQ P1 (GETPOINT "\nStart Point For Text: "))
(setq n 0)
(while (/= n (length lst))
(setq exp (nth n lst))
(command "text" p1 "" "" exp)
(setq n (1+ n) p1 (polar p1 (* 1.5 pi)(* 0.4 (getvar "LTSCALE"))))
)
(SETVAR "LUPREC" OLDP)
(command "layer" "m" oldl "")
))
(SETVAR "OSMODE" OS)
)[/code]Not the most polished or universally useful lisp, but does what I want on blocks I use. Just a strange issue for it to trip up over.
Unless it's text placement relies on current Elev being 0, but I believe it still was when I checked.
0 -
I see a wrong DXF code 1 in act2. Change it to (setq upd (STRCAT (cdr (assoc 2 (entget a))) " " (rtos n)))0
-
@ John: I don't think your Lisp can work on attribute entities. It will work on text entities though. But using it on texts I do not have any problems with the Z-coordinate.0
-
Roy and Vaidas, I am really embarrassed I pasted the wrong routine. I use 'Count' immediately after 'Cat', which is the actual one which would not work.
I wrote them over 20 years ago and use them often, occasionally making that same mistake.
If you guys haven't walked away in disgust, the reason the routine should fail only in this file is secondary to the question of why my entities should be at various elevations.
If the lisp hadn't failed I probably wouldn't have realised something unintended had happened in the file, but one day someone might want to count attributes in a 3d file - it makes me wonder how that would go.
It used to be simple to look at a file 'side on' using the Isometric Views icons, but their command has changed from Vpoint to View and made doing that a chore in V13.
[code](DEFUN c:CAT ()
(SETVAR "CMDECHO" 0)
(SETQ OM (GETVAR "OSMODE"))
(SETVAR "OSMODE" 0)
(if (/= 0 (cdr (assoc 40 (tblsearch "style" (getvar "textstyle")))))
(progn
(princ "\nTextsize must be 0 ")(terpri))
(progn
(setq oldl (getvar "clayer"))
(COMMAND "LAYER" "M" "DEFPOINTS" "")
(SETQ OLDP (GETVAR "LUPREC"))
(SETVAR "LUPREC" 0)
(setq ss (ssget "x" '((0 . "INSERT")(66 . 1))) n 0 p1 nil p1 (getpoint "\nStart Point: "))
(while (/= n (sslength ss))
(setq a (ssname ss n) b (entnext a) c (entnext (entnext a))
d (entnext (entnext (entnext a)))
p (cdr (assoc 2 (entget b)))
q (cdr (assoc 1 (entget b)))
p2 (polar p1 0 (* (getvar "textsize") 12))
p3 (polar p1 0 (* (getvar "textsize") 24))
p4 (polar p1 0 (* (getvar "textsize") 36)))
(if (= "ATTRIB" (cdr (assoc 0 (entget b))))
(progn
(setq p (cdr (assoc 2 (entget a))))
(command "text" p1 "" "" p)))
(if (= "ATTRIB" (cdr (assoc 0 (entget b))))
(progn
(setq q (cdr (assoc 1 (entget b))))
(command "text" p2 "" "" q)))
(if (= "ATTRIB" (cdr (assoc 0 (entget c))))
(progn
(setq r (cdr (assoc 1 (entget c))))
(command "text" p3 "" "" r)))
(if (= "ATTRIB" (cdr (assoc 0 (entget d))))
(progn
(setq s (cdr (assoc 1 (entget d))))
(command "text" p4 "" "" s)))
(setq n (1+ n) p1 (polar p1 (* 1.5 pi)(* (getvar "LTSCALE") 0.4)))
)
(SETVAR "LUPREC" OLDP)
(command "layer" "S" oldl "")
))
(SETVAR "OSMODE" OM)
)[/code]0 -
In my test the (c:CAT) function does not stumble over a non-zero Z-coordinate. The code could do with a cleanup though...
If you want to avoid 'accidental' 3D you can try adding this to your start-up Lisp:
[code](if (zerop (getvar 'worlducs))
(progn
(setvar 'cmdecho 0)
(command "_.ucs" "_world")
(setvar 'cmdecho 1)
)
)
(if (/= (getvar 'elevation) 0.0) (setvar 'elevation 0.0))
(setvar 'osnapz 1) ; This variable is not saved.[/code]0 -
Thanks Roy I will include that.
Yes I know my lisps are rough and ready, though that one only normally only fails on blocks with more attribs than I made it for.
I did check it was world UCS when looking for the problem, now I have pushed everything back to Z=0 I can deliberately make some blocks non 0 and the lisp still works for me too.
So why it would not work previously is as much a mystery.
0