- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello,
I am getting an unexpected result and cannot determine why it's happening. I need some guidance please!
I have an XRecord...
((-1 . <Entity name: 2458ea11b40>) (0 . XRECORD) ...Boring Stuff... (100 . AcDbXrecord) (280 . 1))
...and with this XRecord, after I create it, I use entmod to add custom DXF code items to it. To do that I use this function...
(defun XRecAdd (xR replaceDups iList / return i) ;xR - XRecord ename ;replaceDups - t or nil ;iList - list containing dotted pair lists <Ex: ((1 . "string") (8 . "Defpoints") ...)> (setq return nil) (if (setq xR (entget xR)) (progn (foreach i iList (if (assoc (car i) xR) (if replaceDups (setq xR (subst (cons (car i) (cdr i)) (assoc (car i) xR) xR)) (setq xR (append xR (list (cons (car i) (cdr i))))) );if (setq xR (append xR (list (cons (car i) (cdr i))))) );if );foreach (entmod xR) (setq return t) );progn (prompt "\nCould not find XRecord to add item(s) to...") );if return );defun
...I won't be posting my entire lisp since it is very lengthy, unless absolutely necessary, so please believe me when I say that I have narrowed it to this particular function.
Now, with my XRecord, after it has been created, I will first add a group of entity handles, as a string, to a DXF 1 code like so...
XRecord In: xR = <Entity name: 2458ea11b40> replaceDups = t iList = ((1 . 6D8,6D9,6FE)) ........... (XRecAdd xR replaceDups iList) ........... XRecord Out: ((-1 . <Entity name: 2458ea11b40>) (0 . XRECORD) ...Boring Stuff... (100 . AcDbXrecord) (280 . 1) (1 . 6D8,6D9,6FE))
...this works perfectly fine and returns the expected result.
THEN, when I return to this function to add 2 new items to my XRecord, a DXF 10 code as a point & a DXF 40 code as a double, it returns a DUPLICATE of my DXF 1 code and I have no idea why... So, I inserted a (princ ...) statement to return my XRecord as it was being modified in my function, and it appears that RIGHT BEFORE I get to the (entmod xR) function, I am getting an expected result, then immediately after, I do not. Like so...
XRecord In: xR = <Entity name: 2458ea11b40> (this includes the additional DXF 1 code already) replaceDups = t iList = ((10 380.278 731.166 0.0) (40 . 480.0)) ........... (XRecAdd xR replaceDups iList) vvv Walk-through vvv (defun XRecAdd (xR replaceDups iList / return i) ;xR - XRecord ename ;replaceDups - t or nil ;iList - list containing dotted pair lists <Ex: ((1 . "string") (8 . "Defpoints") ...)> ;xR (as-expected) = ((-1 . <Entity name: 2458ea11b40>) (0 . XRECORD) ...Boring Stuff... (100 . AcDbXrecord) (280 . 1) (1 . 6D8,6D9,6FE)) (setq return nil) (if (setq xR (entget xR)) (progn (foreach i iList (if (assoc (car i) xR) (if replaceDups (setq xR (subst (cons (car i) (cdr i)) (assoc (car i) xR) xR)) (setq xR (append xR (list (cons (car i) (cdr i))))) );if (setq xR (append xR (list (cons (car i) (cdr i))))) );if );foreach ;xR (as-expected) = ((-1 . <Entity name: 2458ea11b40>) (0 . XRECORD) ...Boring Stuff... (100 . AcDbXrecord) (280 . 1) (1 . 6D8,6D9,6FE) (10 380.278 731.166 0.0) (40 . 480.0)) (entmod xR) ;xR (Unexpected!) = ((-1 . <Entity name: 2458ea11b40>) (0 . XRECORD) ...Boring Stuff... (100 . AcDbXrecord) (280 . 1) (1 . 6D8,6D9,6FE) (1 . 6D8,6D9,6FE) (10 380.278 731.166 0.0) (40 . 480.0)) (setq return t) );progn (prompt "\nCould not find XRecord to add item(s) to...") );if return );defun ........... XRecord Out (has Duplicate DXF 1 codes!): ((-1 . <Entity name: 2458ea11b40>) (0 . XRECORD) ...Boring Stuff... (100 . AcDbXrecord) (280 . 1) (1 . 6D8,6D9,6FE) (1 . 6D8,6D9,6FE) (10 380.278 731.166 0.0) (40 . 480.0))
All help on this issue would be appreciated!
Best,
~DD
Solved! Go to Solution.