Author Topic: Problem with entmod - Bug in AutoCAD?  (Read 370 times)

0 Members and 1 Guest are viewing this topic.

Lupo76

  • Bull Frog
  • Posts: 325
Problem with entmod - Bug in AutoCAD?
« on: April 13, 2021, 01:15:02 AM »
Hi,
I have been using this simple code for many years and it has always worked correctly.
However when used with an arc dimension, AutoCAD (various versions) crashes :-o
The same code with the same context works fine in BricsCAD

Code: [Select]
(defun c:test ()
  (setq ogg (car (entsel)))
  (DeleteXdata "EMILISPCA" ogg)
)

(defun DeleteXdata (appname ent /)
  (entmod (list (cons -1 ent)(list -3 (list appname))))
  (princ)
)

I attach a dwg file, the lsp file and a video showing the crash.
Can anyone help me understand or work around the problem?

Thank you!

Marc'Antonio Alessi

  • Swamp Rat
  • Posts: 1189
  • Marco
Re: Problem with entmod - Bug in AutoCAD?
« Reply #1 on: April 13, 2021, 04:07:32 AM »
"ARC_DIMENSION" has "ACAD" Xdata, maybe you need to remove only your Xdata "EMILISPCA"
Code: [Select]
  (-3
      (
         "ACAD"
         (1000 . "DSTYLE")
         (1002 . "{")
         (1070 . 40)
         (1040 . 50.0)
         (1070 . 144)
         (1040 . 1.0)
         (1002 . "}")
      )
      (
         "EMILISPCA"
         (1000 . "TIPOOGG=QUOTEFERRO")
         (1000 . "IDFERRO=DEFAULT_1")
         (1000 . "UM_QUOTE=cm")
      )
   )
Try an audit, the dwg has many errors:
Code: [Select]
...
Name: AcDbBlockGripExpr(45E)
Value: Double - 1.79769e+307
Validation: Invalid
Replaced by: Set to 0

Name: AcDbBlockGripExpr(45F)
Value: Double - 1.79769e+307
Validation: Invalid
Replaced by: Set to 0
...

Lupo76

  • Bull Frog
  • Posts: 325
Re: Problem with entmod - Bug in AutoCAD?
« Reply #2 on: April 13, 2021, 11:41:40 AM »
Hi Marc'Antonio,
I confirm that I only have to remove my "EMILISPCA" Xdata.

The AUDIT command finds no errors in my file which was made from scratch, so the presence of errors would be very strange:

Code: [Select]
Comando: _AUDIT
Correggere qualsiasi errore trovato? [Ś/No] <N>: S
Verifica dell'intestazione
Verifica delle tabelle
Verifica delle entità della fase 1
Fase 1 1100    oggetti controllati
Verifica delle entità della fase 2
Fase 2 1100    oggetti controllati
Verifica dei blocchi
 41      blocchi verificati
Verifica di AcDsRecords

Totale di 0 errori trovati: 0 corretti
Oggetti cancellati 0
Comando:

Furthermore, the crash also occurs on a new empty file by creating a new ARC_DIMENSION object.

Marc'Antonio Alessi

  • Swamp Rat
  • Posts: 1189
  • Marco
Re: Problem with entmod - Bug in AutoCAD?
« Reply #3 on: April 13, 2021, 12:49:22 PM »
...
The AUDIT command finds no errors in my file which was made from scratch, so the presence of errors would be very strange:

Code: [Select]
Comando: _AUDIT
Correggere qualsiasi errore trovato? [Ś/No] <N>: S
Verifica dell'intestazione
Verifica delle tabelle
Verifica delle entità della fase 1
Fase 1 1100    oggetti controllati
Verifica delle entità della fase 2
Fase 2 1100    oggetti controllati
Verifica dei blocchi
 41      blocchi verificati
Verifica di AcDsRecords

Totale di 0 errori trovati: 0 corretti
Oggetti cancellati 0
Comando:
BricsCAD V20 on TEST CON ARCO2.dwg:
Code: [Select]
: _audit
Fix any errors detected? [Yes/No] <No>:y

Name: AcDbBlockGripExpr(45E)
Value: Double - 1.79769e+307
Validation: Invalid
Replaced by: Set to 0

Name: AcDbBlockGripExpr(45F)
Value: Double - 1.79769e+307
Validation: Invalid
Replaced by: Set to 0

Name: AcDbBlockGripExpr(465)
Value: Double - 1.79769e+307
Validation: Invalid
Replaced by: Set to 0

Name: AcDbBlockGripExpr(466)
Value: Double - 1.79769e+307
Validation: Invalid
Replaced by: Set to 0

Name: AcDbBlockGripExpr(474)
Value: Double - 1.79769e+307
Validation: Invalid
Replaced by: Set to 0

Name: AcDbBlockGripExpr(475)
Value: Double - 1.79769e+307
Validation: Invalid
Replaced by: Set to 0

Name: AcDbBlockGripExpr(47C)
Value: Double - 1.79769e+307
Validation: Invalid
Replaced by: Set to 0

Name: AcDbBlockGripExpr(47D)
Value: Double - 1.79769e+307
Validation: Invalid
Replaced by: Set to 0

Name: AcDbProxyObject(6A3)
Value: Owner Id (0)
Validation: Invalid
Replaced by: Set to AcDbProxyObject(6A0)

Name: AcDbProxyObject(6B3)
Value: Owner Id (0)
Validation: Invalid
Replaced by: Set to AcDbProxyObject(6A0)

Name: AcDbProxyObject(6B6)
Value: Owner Id (0)
Validation: Invalid
Replaced by: Set to AcDbProxyObject(6A0)

Name: AcDbProxyObject(6B7)
Value: Owner Id (0)
Validation: Invalid
Replaced by: Set to AcDbProxyObject(6A0)

Name: AcDbProxyObject(6B8)
Value: Owner Id (0)
Validation: Invalid
Replaced by: Set to AcDbProxyObject(6A0)

Name: AcDbProxyObject(6B9)
Value: Owner Id (0)
Validation: Invalid
Replaced by: Set to AcDbProxyObject(6A0)

Name: AcDbProxyObject(6BA)
Value: Owner Id (0)
Validation: Invalid
Replaced by: Set to AcDbProxyObject(6A0)

Name: AcDbProxyObject(6BF)
Value: Owner Id (0)
Validation: Invalid
Replaced by: Set to AcDbProxyObject(6A0)

Name: AcDbProxyObject(6C0)
Value: Owner Id (0)
Validation: Invalid
Replaced by: Set to AcDbProxyObject(6A0)

Name: AcDbProxyObject(6C1)
Value: Owner Id (0)
Validation: Invalid
Replaced by: Set to AcDbProxyObject(6A0)

Name: AcDbProxyObject(6C2)
Value: Owner Id (0)
Validation: Invalid
Replaced by: Set to AcDbProxyObject(6A0)

Name: AcDbProxyObject(6C3)
Value: Owner Id (0)
Validation: Invalid
Replaced by: Set to AcDbProxyObject(6A0)

Name: AcDbProxyObject(708)
Value: Owner Id (0)
Validation: Invalid
Replaced by: Set to AcDbProxyObject(6D9)

Name: AcDbProxyObject(709)
Value: Owner Id (0)
Validation: Invalid
Replaced by: Set to AcDbProxyObject(6D9)

Name: AcDbProxyObject(707)
Value: Owner Id (0)
Validation: Invalid
Replaced by: Set to AcDbProxyObject(6D9)

Name: AcDbProxyObject(70A)
Value: Owner Id (0)
Validation: Invalid
Replaced by: Set to AcDbProxyObject(6D9)

Name: AcDbProxyObject(705)
Value: Owner Id (0)
Validation: Invalid
Replaced by: Set to AcDbProxyObject(6D9)

Name: AcDbProxyObject(704)
Value: Owner Id (0)
Validation: Invalid
Replaced by: Set to AcDbProxyObject(6D9)

Name: AcDbProxyObject(706)
Value: Owner Id (0)
Validation: Invalid
Replaced by: Set to AcDbProxyObject(6D9)

1116 objects audited
Total errors found during audit 27, fixed 27[code]

Lupo76

  • Bull Frog
  • Posts: 325
Re: Problem with entmod - Bug in AutoCAD?
« Reply #4 on: April 13, 2021, 12:52:54 PM »
BricsCAD works correctly.
The problem is in AutoCAD... :-(

ronjonp

  • Needs a day job
  • Posts: 7268
Re: Problem with entmod - Bug in AutoCAD?
« Reply #5 on: April 13, 2021, 12:59:09 PM »
No errors on audit here either but did crash AutoCAD 2022.

Windows 10 x64 - AutoCAD /C3D 2020

Custom Build PC

Marc'Antonio Alessi

  • Swamp Rat
  • Posts: 1189
  • Marco
Re: Problem with entmod - Bug in AutoCAD?
« Reply #6 on: April 13, 2021, 12:59:52 PM »
Hi Marc'Antonio,
I confirm that I only have to remove my "EMILISPCA" Xdata.

Furthermore, the crash also occurs on a new empty file by creating a new ARC_DIMENSION object.
Try this:
Code: [Select]
(defun ALE_RemoveXdata (EntNam AppNam / EntLst TmpLst)
  (setq EntLst (entget EntNam (list AppNam)))
  (foreach ForElm (cdr (assoc -3 EntLst))
    (setq
      TmpLst (cons -3 (list (cons (car ForElm) nil)))
      EntLst (entmod (subst TmpLst (assoc -3 EntLst) EntLst))
    )
  )
  (setq EntLst (entmod (reverse (cdr (reverse EntLst)))))
  (entupd (cdr (assoc -1 EntLst)))
)

(defun c:test2 ( / EntNam)
  (setq EntNam (car (entsel)))
  (ALE_RemoveXdata EntNam "EMILISPCA")
)

Marc'Antonio Alessi

  • Swamp Rat
  • Posts: 1189
  • Marco
Re: Problem with entmod - Bug in AutoCAD?
« Reply #7 on: April 13, 2021, 01:13:32 PM »
No errors on audit here either but did crash AutoCAD 2022.
which version of BricsCAD?
Tested on V19 > less errors...:
Code: [Select]
: _audit
Correggere gli eventuali errori rilevati? [Si/No] <No>:s
Nome: AcDbBlockGripExpr(45E)
Valore: Double - 1.79769e+307
Validazione: Non valido
Sostituito da: Impostato a 0


Nome: AcDbBlockGripExpr(45F)
Valore: Double - 1.79769e+307
Validazione: Non valido
Sostituito da: Impostato a 0


Nome: AcDbBlockGripExpr(465)
Valore: Double - 1.79769e+307
Validazione: Non valido
Sostituito da: Impostato a 0


Nome: AcDbBlockGripExpr(466)
Valore: Double - 1.79769e+307
Validazione: Non valido
Sostituito da: Impostato a 0


Nome: AcDbBlockGripExpr(474)
Valore: Double - 1.79769e+307
Validazione: Non valido
Sostituito da: Impostato a 0


Nome: AcDbBlockGripExpr(475)
Valore: Double - 1.79769e+307
Validazione: Non valido
Sostituito da: Impostato a 0


Nome: AcDbBlockGripExpr(47C)
Valore: Double - 1.79769e+307
Validazione: Non valido
Sostituito da: Impostato a 0


Nome: AcDbBlockGripExpr(47D)
Valore: Double - 1.79769e+307
Validazione: Non valido
Sostituito da: Impostato a 0


1116 oggetti controllati
Errori totali rilevati durante la verifica 8, risolti 8

ronjonp

  • Needs a day job
  • Posts: 7268
Re: Problem with entmod - Bug in AutoCAD?
« Reply #8 on: April 13, 2021, 01:51:30 PM »
I don't have Bricscad. Did the audit using AutoCAD 2022.

Windows 10 x64 - AutoCAD /C3D 2020

Custom Build PC

Lupo76

  • Bull Frog
  • Posts: 325
Re: Problem with entmod - Bug in AutoCAD?
« Reply #9 on: April 14, 2021, 07:02:11 AM »
Try this:
Code: [Select]
(defun ALE_RemoveXdata (EntNam AppNam / EntLst TmpLst)
  (setq EntLst (entget EntNam (list AppNam)))
  (foreach ForElm (cdr (assoc -3 EntLst))
    (setq
      TmpLst (cons -3 (list (cons (car ForElm) nil)))
      EntLst (entmod (subst TmpLst (assoc -3 EntLst) EntLst))
    )
  )
  (setq EntLst (entmod (reverse (cdr (reverse EntLst)))))
  (entupd (cdr (assoc -1 EntLst)))
)

(defun c:test2 ( / EntNam)
  (setq EntNam (car (entsel)))
  (ALE_RemoveXdata EntNam "EMILISPCA")
)

Hi Marc'Antonio,
thanks to your function I was able to work around the AutoCAD bug and solve the problem!

Thank you!

Marc'Antonio Alessi

  • Swamp Rat
  • Posts: 1189
  • Marco
Re: Problem with entmod - Bug in AutoCAD?
« Reply #10 on: April 14, 2021, 08:58:17 AM »
Hi Marc'Antonio,
thanks to your function I was able to work around the AutoCAD bug and solve the problem!

Thank you!
:)  It was an old question... http://www.theswamp.org/index.php?topic=41456.msg465573#msg465573
IMHO I think this is not a Bug  8)

Lupo76

  • Bull Frog
  • Posts: 325
Re: Problem with entmod - Bug in AutoCAD?
« Reply #11 on: April 14, 2021, 09:08:54 AM »
:)  It was an old question... http://www.theswamp.org/index.php?topic=41456.msg465573#msg465573
IMHO I think this is not a Bug  8)

It was my post! I had completely forgotten it.
It came up again on a referral from a client of mine.

In my opinion this is a bug, my code works with all object types except ARC_DIMENSION, I see no reason to think this is normal.
Also the problem only occurs in AutoCAD, while BricsCAD has no problem here.
Also, again in my opinion, a system crash is always a bug as it is something unexpected.

Marc'Antonio Alessi

  • Swamp Rat
  • Posts: 1189
  • Marco
Re: Problem with entmod - Bug in AutoCAD?
« Reply #12 on: April 14, 2021, 10:57:05 AM »
:)  It was an old question... http://www.theswamp.org/index.php?topic=41456.msg465573#msg465573
IMHO I think this is not a Bug  8)

It was my post! I had completely forgotten it.
It came up again on a referral from a client of mine.

In my opinion this is a bug, my code works with all object types except ARC_DIMENSION, I see no reason to think this is normal.
Also the problem only occurs in AutoCAD, while BricsCAD has no problem here.
Also, again in my opinion, a system crash is always a bug as it is something unexpected.
The difference is that BricsCAD NEVER removes "ACAD" Xdata ...        and I don't know (and I've never tried)  if it allows their modification...