@Marc'Antonio Alessi: Thanks for confirming this.:yes: :)
Note that entnext (no doubt a close cousin of entlast) is also buggy.
Maybe this can help: https://www.theswamp.org/index.php?topic=45732.msg509031#msg509031Thanks for that link. I'll study the topic. I vaguely remember reading only parts of it in the past. :roll:
@ribarm: (ssget "_L") can return nil...
This is not related to the subject of the discussion but, since you use Bricscad, there is another strange behavior in the old versions concerning ssget in empty DWG:Maybe this can help: https://www.theswamp.org/index.php?topic=45732.msg509031#msg509031Thanks for that link. I'll study the topic. I vaguely remember reading only parts of it in the past. :roll:
(defun C:TestEmptyDWG ( / Ss_Set)
(print (getvar "ACADVER"))
(if (setq Ss_Set (ssget "_X"))
(progn
(print (cdr (assoc 0 (entget (ssname Ss_Set 0)))))
(princ (strcat " sslength = " (itoa (sslength Ss_Set))))
)
(print "no ssget entities in DWG")
)
(princ)
)
: TESTEMPTYDWG
"20.0 BricsCAD"
"no ssget entities in DWG"
: TESTEMPTYDWG
"19.1 BricsCAD"
"VIEWPORT" sslength = 1
This is my version of Ss-After:(defun ALE_Ss-After (EntNam / SelSet)
(cond
( (not EntNam) (ssget "_X" '((0 . "~VIEWPORT"))) ); "~VIEWPORT" x Bricscad
( (setq EntNam (entnext EntNam))
(setq SelSet (ssadd EntNam))
(while (setq EntNam (entnext EntNam))
(if (entget EntNam) (ssadd EntNam SelSet))
)
SelSet
)
)
)
@Marc'Antonio Alessi:You're right, unfortunately I can not replicate the problem, I started from an empty metric DWG...
Are you testing this with the same dwg? Because I cannot reproduce this in BC V14 or V15. Maybe in one case you are testing with a dwg that (still) contains a 'main' paper space viewport. Which is an invisible entity that cannot be erased through normal user actions. To delete it you have to use vla-delete, entdel will not work.
EDIT: 'vla-deleting' a main viewport results in an _Audit issue. So such a VP should not be deleted.
(defun C:TestEmptyDWGm ( / Ss_Set)
(print (getvar "ACADVER"))
(if (setq Ss_Set (ssget "_X"))
(progn
(print (cdr (assoc 0 (entget (ssname Ss_Set 0)))))
(princ (strcat " sslength = " (itoa (sslength Ss_Set))))
)
(print "no ssget entities in DWG")
)
(princ)
)
(defun C:TestEmptyDWG1 ( / Ss_Set)
(setvar "CTAB" "Layout1")
(setvar "CTAB" "Model")
(if (setq Ss_Set (ssget "_X"))
(progn
(print (cdr (assoc 0 (entget (ssname Ss_Set 0)))))
(princ (strcat " sslength = " (itoa (sslength Ss_Set))))
)
(print "no ssget entities in DWG")
)
(princ)
)
(defun C:TestEmptyDWG2 ( / Ss_Set)
(setvar "CTAB" "Layout2")
(setvar "CTAB" "Model")
(if (setq Ss_Set (ssget "_X"))
(progn
(print (cdr (assoc 0 (entget (ssname Ss_Set 0)))))
(princ (strcat " sslength = " (itoa (sslength Ss_Set))))
)
(print "no ssget entities in DWG")
)
(princ)
)
;--------------------------
: (C:TESTEMPTYDWGm)
"19.1 BricsCAD"
"no ssget entities in DWG"
: (C:TESTEMPTYDWG1)
"VIEWPORT" sslength = 1
: (C:TESTEMPTYDWG2)
"VIEWPORT" sslength = 2
;--------------------------
;--------------------------
: (C:TESTEMPTYDWGm)
"21.0 BricsCAD"
"no ssget entities in DWG"
: (C:TESTEMPTYDWG1)
"VIEWPORT" sslength = 1
: (C:TESTEMPTYDWG2)
"VIEWPORT" sslength = 2
;--------------------------
;--------------------------
Comando: (C:TESTEMPTYDWGm)
"19.0s (LMS Tech)"
"no ssget entities in DWG"
Comando: (C:TESTEMPTYDWG1)
"VIEWPORT" sslength = 1
Comando: (C:TESTEMPTYDWG2)
"VIEWPORT" sslength = 2
;--------------------------