Behavior of inputting variables in a dotted pair

Behavior of inputting variables in a dotted pair

Jonathan_Bell82GXG
Enthusiast Enthusiast
209 Views
1 Reply
Message 1 of 2

Behavior of inputting variables in a dotted pair

Jonathan_Bell82GXG
Enthusiast
Enthusiast

I've created a helper function to offset a circle and then change the color of the offset to blue. Within the helper function, I'm confused as to why (cons 62 circOSColor) has no effect on the color of the offset, but '((62 . 5)) does work. It seems you can't use variables in a dotted pair (either explicitly or with the cons function)?

 

Helper function:

(defun offsetCircle (entList circOffset circOSColor /)  

    ; create circular offset
    (vla-offset (vlax-ename->vla-object (cdr (car entList))) circOffset)

    ; change offset color 
    (setq offsetEList (entget (entlast)))
    (setq offsetEList (append 
                          (vl-remove (assoc '420 offsetEList) 
                                     offsetEList
                          )
                          (cons 62 circOSColor)       ;'((62 . 5))
                      )
    )
    (entmod offsetEList)
)

 

Function call:

(setq circOffset 4) ; 4 inch offset (circle)
(setq circOSColor 5) ; offset color index (circle)

(offsetCircle entList circOffset circOSColor)

 

0 Likes
Accepted solutions (1)
210 Views
1 Reply
Reply (1)
Message 2 of 2

Kent1Cooper
Consultant
Consultant
Accepted solution

@Jonathan_Bell82GXG wrote:

....

....
    (setq offsetEList (append 
                          (vl-remove (assoc '420 offsetEList) 
                                     offsetEList
                          )
                          (list (cons 62 circOSColor))       ;'((62 . 5))
                      )
    )
....

Put the (cons) function for the color into another list as above, and as you did with the 5 value.  Without that, the 62 and color number go into the overall entity data list as independent pieces, not as a color-assignment sub-list [or not even -- it complains about a dotted-pair there].  To illustrate with simple lists:

Command: (append '((a 1) (b 2) (c 3)) '(d 4))
((A 1) (B 2) (C 3) D 4)

but

Command: (append '((a 1) (b 2) (c 3)) (list '(d 4)))
((A 1) (B 2) (C 3) (D 4))

Kent Cooper, AIA
0 Likes