Author Topic: Delete all attributes in Block (AcDbBlockReference)  (Read 1883 times)

0 Members and 1 Guest are viewing this topic.

Marc'Antonio Alessi

  • Swamp Rat
  • Posts: 1451
  • Marco
Delete all attributes in Block (AcDbBlockReference)
« on: March 04, 2021, 12:36:41 PM »
Code: [Select]
(defun C:Test ( / BlockEnt BlockDat BlockObj)
  (setq
    BlockEnt (car (entsel))
    BlockDat (entget BlockEnt)
    BlockObj (vlax-ename->vla-object BlockEnt)
  )
  (princ (strcat "\nBefore > Dxf 66       : "  (itoa (cdr (assoc 66 BlockDat)))))
  (princ         "\nBefore > HasAttributes: ") (princ (vla-get-hasattributes BlockObj))
  (foreach ForElm (vlax-invoke BlockObj 'getattributes)
    (vl-catch-all-apply 'vla-delete (list ForElm))
  )
  (princ (strcat "\nAfter1 > Dxf 66       : "  (itoa (cdr (assoc 66 BlockDat)))))
  (princ         "\nAfter  > HasAttributes: ") (princ (vla-get-hasattributes BlockObj))
  (entupd BlockEnt)
  (princ (strcat "\nAfter2 > Dxf 66       : "  (itoa (cdr (assoc 66 BlockDat)))))
  (princ)
)
Code: [Select]
BricsCAD
Before > Dxf 66       : 1
Before > HasAttributes: :VLAX-TRUE
After1 > Dxf 66       : 1
After  > HasAttributes: :VLAX-FALSE <<<
After2 > Dxf 66       : 1
Code: [Select]
AutoCAD
Before > Dxf 66       : 1
Before > HasAttributes: :vlax-true
After1 > Dxf 66       : 1
After  > HasAttributes: :vlax-true <<<
After2 > Dxf 66       : 1

In BricsCAD I get this error:  >>> Edit: only if I delete attribs in AcDbBlockTableRecord see replay #3
Name: AcDbBlockTableRecord(3E9D7)
Value: hasAttributeDefinitions flag is true, but record has no AttributeDefinitions
Validation: Disparity
Replaced by: Set to False >>> but it IS recovered!

how to avoid this problem?

roy_043

  • Water Moccasin
  • Posts: 1895
  • BricsCAD 18
Re: Delete all attributes in Block (AcDbBlockReference)
« Reply #1 on: March 05, 2021, 05:34:20 AM »
Entmake a new INSERT.

Marc'Antonio Alessi

  • Swamp Rat
  • Posts: 1451
  • Marco
Re: Delete all attributes in Block (AcDbBlockReference)
« Reply #2 on: March 05, 2021, 09:18:21 AM »
Entmake a new INSERT.
Thanks, I'm working on this topic because there are some differences between BricsCAD and AutoCAD and I have to correct what I wrote:
Name: AcDbBlockTableRecord(3E9D7)
Value: hasAttributeDefinitions flag is true, but record has no AttributeDefinitions
Validation: Disparity
Replaced by: Set to False
this error occurred after Audit if I delete all the attributes in the block definition (BLOCK)  and not in the inserted block (INSER), as soon as I have some other news I will write it.
Marco

Marc'Antonio Alessi

  • Swamp Rat
  • Posts: 1451
  • Marco
Re: Delete all attributes in Block (AcDbBlockReference)
« Reply #3 on: March 05, 2021, 10:13:07 AM »
Here I am, if I use this function to delete attribs in AcDbBlockTableRecord:
Code: [Select]
; VlaBlk > AcDbBlockTableRecord > #<VLA-OBJECT IOdaBlock 0000000039FF2400>
;
(defun test2 (VlaBlk) 
  (vlax-for ObjFor VlaBlk
    (if (= "AcDbAttributeDefinition" (vla-get-objectname ObjFor))
      (progn
        (princ " Attrib > ")   (prin1 (vla-get-TextString ObjFor))  (princ "\n")
        (prin1 (vl-catch-all-apply 'vla-delete (list ObjFor)))
      )
      (progn (princ " Other > ")   (prin1 (vla-get-objectname ObjFor)) (princ "\n"))
    )
  )
  (princ)
)

After audit I get this error ONLY in BricsCAD (tested in V20) the error IS recovered!

Name: AcDbBlockTableRecord(3E9D7)
Value: hasAttributeDefinitions flag is true, but record has no AttributeDefinitions
Validation: Disparity
Replaced by: Set to False


roy_043

  • Water Moccasin
  • Posts: 1895
  • BricsCAD 18
Re: Delete all attributes in Block (AcDbBlockReference)
« Reply #4 on: March 05, 2021, 11:08:25 AM »
Obviously a bug. The 'hasAttributeDefinitions flag' is actually stored on the "BLOCK" entity (gc 70). But I am not able to entmod it.
This code does not work (BricsCAD V18).
Code - Auto/Visual Lisp: [Select]
  1. (defun FixBlkDef (blkDef / elst)
  2.   (setq elst (entget (cdr (assoc 360 (entget (vlax-vla-object->ename blkDef))))))
  3.   (entmod
  4.     (subst
  5.       (cons 70 (logand (cdr (assoc 70 elst)) (~ 2)))
  6.       (assoc 70 elst)
  7.       elst
  8.     )
  9.   )
  10. )

Marc'Antonio Alessi

  • Swamp Rat
  • Posts: 1451
  • Marco
Re: Delete all attributes in Block (AcDbBlockReference)
« Reply #5 on: March 05, 2021, 11:57:04 AM »
Maybe it is not possible with Lisp, I do not see a  "HasAttributeDefinitions"  property.