Author Topic: DXF 8 (layer) on BLOCK definition  (Read 2850 times)

0 Members and 1 Guest are viewing this topic.

Marc'Antonio Alessi

  • Swamp Rat
  • Posts: 1453
  • Marco
DXF 8 (layer) on BLOCK definition
« on: November 09, 2018, 10:24:23 AM »
What is it for (8 . "0")  >  Layer = "0"  on BLOCK definition?
Code: [Select]
((-1 . <Nome entità: 7ff4a3d5a370>)
(0 . "BLOCK") (330 . <Nome entità: 7ff4a3d5a360>)
(5 . "FDA5F") (100 . "AcDbEntity")
(67 . 0)
(8 . "0")
(100 . "AcDbBlockBegin")
(70 . 0) (10 100.0 100.0 0.0)
(-2 . <Nome entità: 7ff4a3d5a380>)
(2 . "pippo")
(1 . "pippo"))


; IAcadEntity: Interfaccia entità AutoCAD
; valori della proprietà:
;   Application (RO) = #<VLA-OBJECT IAcadApplication 00007ff68e713318>
;   Document (RO) = #<VLA-OBJECT IAcadDocument 000000002fceef28>
;   EntityTransparency = "DaLayer"
;   Handle (RO) = "FDA70"
;   HasExtensionDictionary (RO) = 0
;   Hyperlinks (RO) = #<VLA-OBJECT IAcadHyperlinks 000000002fe087e8>
;   Layer = "0"
;   Linetype = "BYLAYER"
;   LinetypeScale = 1.0
;   Lineweight = -1
;   Material = "ByLayer"
;   ObjectID (RO) = 152
;   ObjectID32 (RO) = 152
;   ObjectName (RO) = "AcDbBlockBegin"
;   OwnerID (RO) = 153
;   OwnerID32 (RO) = 153
;   PlotStyleName = "ByLayer"
;   TrueColor = #<VLA-OBJECT IAcadAcCmColor 000000002fe08ea0>
;   Visible = -1

Lee Mac

  • Seagull
  • Posts: 12914
  • London, England
Re: DXF 8 (layer) on BLOCK definition
« Reply #1 on: November 09, 2018, 05:48:16 PM »
I would always suggest using layer "0" for the BLOCK and ENDBLK entities, else layers assigned to these entities cannot be purged; as far as I'm aware, the layer assigned to these entities have no graphical effect on the resulting block reference.

kirby

  • Newt
  • Posts: 132
Re: DXF 8 (layer) on BLOCK definition
« Reply #2 on: November 09, 2018, 06:25:55 PM »
May just be part of a standard entity definition. eg. Layer of 'header' entity of heavy polyline has a layer, so does a block definition.  I know drawing can go haywire if a polyline vertices are edited onto a different layer than the header, but same isn't true about block definition.

Marc'Antonio Alessi

  • Swamp Rat
  • Posts: 1453
  • Marco
Re: DXF 8 (layer) on BLOCK definition
« Reply #3 on: November 10, 2018, 11:24:51 AM »
Thanks, I'm trying to write a function that speeds up block creations, suggestions?
Code: [Select]
(setq #OneEnt (entlast)  #Countr 0)
 (Benchmark '(
 (test_EntMake1 #OneEnt)
 (test_EntMake2 #OneEnt)
 (test_vl-cmdf1 #OneEnt)
))
Benchmark.lsp | © 2005 Michael Puckett | All Rights Reserved
Elapsed milliseconds / relative speed for 2048 iteration(s):
    (TEST_ENTMAKE2 #ONEENT)......4891 / 2.45 <fastest>
    (TEST_ENTMAKE1 #ONEENT)......6218 / 1.93
    (TEST_VL-CMDF1 #ONEENT).....11984 / 1 <slowest>

>TEST_ENTMAKE1 with (tblsearch "BLOCK" BlkNam) is slower
Code: [Select]
(defun test_EntMake1 (SsOrEn)
  (ALE_Block_Draw_EntMake1 SsOrEn (strcat "EntMake1" (itoa (setq #Countr (1+ #Countr)))) '(0. 0. 0.))
  (entdel SsOrEn)
)
(defun test_EntMake2 (SsOrEn)
  (ALE_Block_Draw_EntMake2 SsOrEn (strcat "EntMake1" (itoa (setq #Countr (1+ #Countr)))) '(0. 0. 0.))
  (entdel SsOrEn)
)
(defun test_vl-cmdf1 (SsOrEn)
  (ALE_Block_Draw_vl-cmdf SsOrEn (strcat "vl-cmdf" (itoa (setq #Countr (1+ #Countr)))) '(0. 0. 0.))
  (entdel SsOrEn)
)
(defun ALE_Block_Draw_EntMake1 (SsOrEn BlkNam BlkIns)
  (cond
    ( (not (snvalid BlkNam))     (alert (strcat  BlkNam ": nome non valido per la creazione del blocco.")) ) ;restituisce nil
    ( (tblsearch "BLOCK" BlkNam) (alert (strcat  BlkNam ": blocco già esistente.")) ) ;restituisce nil
    ( (entmake
        (list
         '(0   . "BLOCK")
         '(100 . "AcDbEntity")         ; recommended
         '(100 . "AcDbBlockBegin")     ; recommended
          (cons  2 BlkNam)             ; required
         '(8  . "0")                   ; recommended
         '(70 .  0)                    ; required [NOTE 0 if no attributes]
          (cons 10 (trans BlkIns 1 0)) ; required trans da eventuale User (current UCS) a World (WCS)
        )
      )
      (if (equal (type SsOrEn) 'PICKSET)
        (foreach ForElm (vl-remove-if 'listp (mapcar 'cadr (ssnamex SsOrEn))) ; nuovo metodo per elaborare entità in un gruppo di selezione
          (if (entmake (entget ForElm))
            (entdel ForElm)
            (alert (strcat "errore 1 nella creazione del blocco: " BlkNam))
          )
        )
        (if (entmake (entget SsOrEn))
          (entdel SsOrEn)
          (alert (strcat "errore 2 nella creazione del blocco: " BlkNam))
        )
      )
      (entmake '((0 . "ENDBLK") (8 . "0") (100 . "AcDbBlockEnd"))) ; restituisce BlkNam se buon fine
    )
    ( T (alert (strcat "errore 3 nella creazione del blocco: " BlkNam)) ) ;restituisce nil
  )
)
(defun ALE_Block_Draw_EntMake2 (SsOrEn BlkNam BlkIns)
  (cond
    ( (entmake
        (list
         '(0   . "BLOCK")
         '(100 . "AcDbEntity")         ; recommended
         '(100 . "AcDbBlockBegin")     ; recommended
          (cons  2 BlkNam)             ; required
         '(8  . "0")                   ; recommended
         '(70 .  0)                    ; required [NOTE 0 if no attributes]
          (cons 10 (trans BlkIns 1 0)) ; required trans da eventuale User (current UCS) a World (WCS)
        )
      )
      (if (equal (type SsOrEn) 'PICKSET)
        (foreach ForElm (vl-remove-if 'listp (mapcar 'cadr (ssnamex SsOrEn))) ; nuovo metodo per elaborare entità in un gruppo di selezione
          (if (entmake (entget ForElm))
            (entdel ForElm)
            (alert (strcat "errore 1 nella creazione del blocco: " BlkNam))
          )
        )
        (if (entmake (entget SsOrEn))
          (entdel SsOrEn)
          (alert (strcat "errore 2 nella creazione del blocco: " BlkNam))
        )
      )
      (entmake '((0 . "ENDBLK") (8 . "0") (100 . "AcDbBlockEnd"))) ; restituisce BlkNam se buon fine
    )
    ( T (alert (strcat "errore 3 nella creazione del blocco: " BlkNam)) ) ;restituisce nil
  )
)
(defun ALE_Block_Draw_vl-cmdf (SsOrEn BlkNam BlkIns)
  (vl-cmdf "_.BLOCK" BlkNam BlkIns SsOrEn "")
)

Lee Mac

  • Seagull
  • Posts: 12914
  • London, England
Re: DXF 8 (layer) on BLOCK definition
« Reply #4 on: November 10, 2018, 12:21:19 PM »
If you're looking for performance, avoid ssnamex - this is known to be slow.

You may wish to consider the methods used in these programs.

efernal

  • Bull Frog
  • Posts: 206
Re: DXF 8 (layer) on BLOCK definition
« Reply #5 on: November 10, 2018, 04:23:15 PM »
My tools ...
I do not send .dwg files, but .fas files, which are much smaller and efficient ...
e.fernal

Marc'Antonio Alessi

  • Swamp Rat
  • Posts: 1453
  • Marco
Re: DXF 8 (layer) on BLOCK definition
« Reply #6 on: November 11, 2018, 03:20:54 AM »
My tools ...
I do not send .dwg files, but .fas files, which are much smaller and efficient ...
Interesting, never had this idea... do you think this method is valid even for very large files?
Better than DXF?

Marc'Antonio Alessi

  • Swamp Rat
  • Posts: 1453
  • Marco
Re: DXF 8 (layer) on BLOCK definition
« Reply #7 on: November 11, 2018, 03:51:13 AM »
If you're looking for performance, avoid ssnamex - this is known to be slow.

You may wish to consider the methods used in these programs.
Lee, I had already seen your link… all the comments are from CAB:
'(100. "AcDbEntity"); recommended
'(100. "AcDbBlockBegin"); recommended
(cons 2 BlkNam); required
'(8. "0"); recommended
...
you're right repeat is faster, and to think that once I used it... now I have to go back to the old road:
Code: [Select]
(defun test_ssnamex (SsOrEn)
  (foreach ForElm (vl-remove-if 'listp (mapcar 'cadr (ssnamex SsOrEn)))
    (entget ForElm)
  )
)
(defun test_repeat (SsOrEn / i)
  (repeat (setq i (sslength SsOrEn))
    (entget (ssname SsOrEn (setq i (1- i))))
  )
)
(sslength (setq Aselset (ssget "_X"))) > 14672

(Benchmark '(
 (test_ssnamex Aselset)
 (test_repeat Aselset)
 (test_ssnamex Aselset)
 (test_repeat Aselset)
))

Benchmark.lsp | © 2005 Michael Puckett | All Rights Reserved
Elapsed milliseconds / relative speed for 8 iteration(s):
    (TEST_REPEAT ASELSET)......1172 / 1.27 <fastest>
    (TEST_REPEAT ASELSET)......1187 / 1.25
    (TEST_SSNAMEX ASELSET).....1453 / 1.02
    (TEST_SSNAMEX ASELSET).....1484 / 1 <slowest>

efernal

  • Bull Frog
  • Posts: 206
Re: DXF 8 (layer) on BLOCK definition
« Reply #8 on: November 11, 2018, 06:31:42 PM »
Interesting, never had this idea... do you think this method is valid even for very large files?
Better than DXF?


I use this (and others) functions to build blocks, styles, layers, etc, extracting the data direct from these entities...
e.fernal