Is there something wrong with entmake for changing the properties of a CIRCLE?

Hello,

I'm trying to get a lisp program to work in BricsCad (Autocad didn't have problems with this code).
This is for changing the appearance of entities, color and linetype. With lines and arcs etc. no problems, but changing the properties of a circle with entmake does not work.
Does someone know what is going wrong? Or is this an error of the entmake function in BricsCad?
(version 17.1.17)
(defun modln ( nr / a b c d n nam mn) (setq a (ssget)) (if (/= a nil) (progn (if (not (tblsearch "ltype" "center")) (command "linetype" "L" "center" "" "")) (if (not (tblsearch "ltype" "hidden")) (command "linetype" "L" "hidden" "" "")) (setq b (sslength a)) (setq n 0) (repeat b (setq nam (ssname a n)) (setq n (1+ n)) (setq ent (entget nam)) (if (or (= (dxf 0 ent) "CIRCLE") (= (dxf 0 ent) "LINE") (= (dxf 0 ent) "ARC") (= (dxf 0 ent) "LWPOLYLINE") (= (dxf 0 ent) "ELLIPSE")) (progn (if (= nr 1)(progn (setq c (cons 62 256));color (setq d (cons 6 "Bylayer"));linetype ));progn if (if (= nr 2)(progn (setq c (cons 62 6));color (setq d (cons 6 "Center"));linetype ));progn if (if (= nr 3)(progn (setq c (cons 62 5));color (setq d (cons 6 "HIDDEN"));linetype ));progn if (if (= nr 4)(progn (setq c (cons 62 252));color (setq d (cons 6 "Bylayer"));linetype ));progn if (if (= nr 5)(progn (setq c (cons 62 11));color (setq d (cons 6 "dashdot"));linetype ));progn if (if (= nr 6)(progn (setq c (cons 62 7));color (setq d (cons 6 "Bylayer"));linetype ));progn if ; (setq mn 0) (if (and (= (dxf 6 ent) nil) (/= (cdr d) "Bylayer")) (progn (setq mn 1) (setq ent (append ent (list d)))) (setq ent (subst d (assoc 6 ent) ent)) );if (if (and (= (dxf 62 ent) nil) (/= (cdr c) 256)) (progn (setq mn 1) (setq ent (append ent (list c))) (setq ent (append ent (list d)))) (setq ent (subst c (assoc 62 ent) ent)) );if (if (= mn 1)(progn (entdel (dxf -1 ent)) (entmake ent))(entmod ent)) (princ) );progn );if line, arc or circle );repeat );progn );if a /=0 );defun ; (defun dxf (code elist) (cdr (assoc code elist)) );defun

Comments

  • What you are doing is strange. To change the properties of an entity you delete it and create a new entity. IMO this is not a good idea.

    Two solutions:

    1.
    Change:
    (if (= mn 1)(progn (entdel (dxf -1 ent)) (entmake ent))(entmod ent))
    To:
    (entmod ent)

    2.
    Change the order of the entity list (3x):
    Change e.g.:
    (setq ent (append ent (list c)))
    To:
    (setq ent (cons c ent))

  • Thanks Roy! First solution did the trick!

    I see it isn't the best way to do this, but in Autocad it worked therefore we used it. It is code made by a former colleague, why he made it this way I don't know. But now it works also for BricsCad, so thats great!

  • Hi, Pjotr,

    another detail to notice : table entries (layer, block, styles etc) are case-insensitive by definition ...
    so if you check against a particular name like "ByLayer" - then the spelling is never guaranteed;
    so the Lisp code must use case-insensitive check like

    (if (/= (strcase name) "BYLAYER) ...)

    otherwise you can get delicate problems :-)
    many greetings !

This discussion has been closed.