Good Morning everyone,
I am having a bit of a dilemma regarding the use of 'Equal' and also the use of the operator 'less than' (<).
My story: I have several arcs in a drawing that are displayed as nothing more than points. At a closer look, these arcs are basically with a zero length. So I'm trying to replace them with circles (which they should be anyway - long story) and this is where I am having my issue.
Here's what I'm doing:
(setq origLayr (getvar "clayer")
origColr (getvar "cecolor")
origLTyp (getvar "celtype")
origLWgt (getvar "celweight")
i -1
SS (ssget '((0 . "ARC"))) ; "_X"
)
(while (setq Obj (ssname SS (setq i (1+ i))))
(if (setq eList (entget Obj))
(progn
(setq objAnglS (cdr (assoc 50 eList))
objAnglE (cdr (assoc 51 eList)))
(if [color=red](= (equal ArcAnglS ArcAnglE 0.001) T)[/color] ; or
; [color=green](and (> ArcAnglS 0.25)(> ArcAnglE 0.25))[/color]
(progn
(setq objLayr (cdr (assoc 8 eList))
objColr (cdr (assoc 62 eList))
objLTyp (cdr (assoc 6 eList))
objLWgt (cdr (assoc 370 eList))
objCtrPT (cdr (assoc 10 eList))
objRad (cdr (assoc 40 eList))
)
(if (= objColr nil)
(setvar "cecolor" "ByLayer")
(progn
(setq objColr (itoa objColr))
(setvar "cecolor" objColr)
)
)
(if (= objLWgt nil)
(setvar "celweight" -1)
(setvar "celweight" objLWgt)
)
(if (= objLTyp nil)
(setvar "celtype" "ByLayer")
(setvar "celtype" objLTyp)
)
(setvar "clayer" objLayr)
(command ".circle" objCtrPT objRad)
(command ".erase" Obj "")
) ; progn
) ; if
) ; progn
) ; if
) ; while
Initially, I had several arcs that had a length (DXF 50 & 51) of 0.000. So I was using the code above in green. But I had to reverse the operator in order to get it to work. So the 'ArcAnglS' and 'ArcAnglE' had to be Greater than the 0.25 in order for the routine to recognize arcs smaller than 0.25. I don't know why.
Then on a second drawing I came across these arcs and had to change my code to what is now in red above:
Select object: ((-1 . <Entity name: 7ebb88f0>) (0 . "ARC") (330 . <Entity name:
7e935ee8>) (5 . "10A4E") (100 . "AcDbEntity") (67 . 0) (410 . "Model") (8 .
"0") (62 . 0) (100 . "AcDbCircle") (10 3212.39 1104.38 0.0) (40 . 2.25014) (210
0.0 0.0 1.0) (100 . "AcDbArc") (50 . 2.00662) (51 . 2.00662))
Select object: ((-1 . <Entity name: 7ebb8910>) (0 . "ARC") (330 . <Entity name:
7e935ee8>) (5 . "10A52") (100 . "AcDbEntity") (67 . 0) (410 . "Model") (8 .
"0") (62 . 0) (100 . "AcDbCircle") (10 3235.45 1075.96 0.0) (40 . 0.750047)
(210 0.0 0.0 1.0) (100 . "AcDbArc") (50 . 0.435826) (51 . 0.435826))
So being zero length arcs, it makes sense to 'Equal' the two points
(equal ArcAnglS ArcAnglE 0.001)
But the code is running regardless of whether the two variables are equal or not.
If I set the code to this:
(if [color=red](/= (equal ArcAnglS ArcAnglE 0.001) T)[/color]
Then the 'If' statement does not run, WHEN IT SHOULD.
I'm hoping you guys can see some stupid mistake on my part and show me, because I feel like I'm losing my mind. I'm beginning to write code in reverse of what should be. 'Greater than' is now 'Less than', 'Equal' is now '/=', etc.
Thanks for your help.