0 Members and 1 Guest are viewing this topic.
((-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
(setq #OneEnt (entlast) #Countr 0) (Benchmark '( (test_EntMake1 #OneEnt) (test_EntMake2 #OneEnt) (test_vl-cmdf1 #OneEnt)))Benchmark.lsp | © 2005 Michael Puckett | All Rights ReservedElapsed 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
(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 ""))
My tools ... I do not send .dwg files, but .fas files, which are much smaller and efficient ...
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.
(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 ReservedElapsed 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>