System variable for block edit status

System variable for block edit status

jon.t800
Contributor Contributor
1,359 Views
8 Replies
Message 1 of 9

System variable for block edit status

jon.t800
Contributor
Contributor

Hello,

 

Does anyone know what is the system variable checked by "Bclose" to know whether a drawing needs to be saved or not?

 

For example, DBMOD is checked to see if any changes were made to the drawing itself.

 

Here's a little lisp to toggle in and out of blocks conveniently, regardless of save-state:

 

(defun C:BB () ;Quick Block Entry
;gonna try and nest in a save + refclose if already in refedit mode
(if (= (getvar 'blockeditor) 1)
    (progn
    (vl-cmdf "_.Bsave")
    (vl-cmdf "_.Bclose")

;i wanted to do this originally:
; (vl-cmdf "_.Bclose" "_S")
;but if there is no changes to the block, the S would go nowhere
 
   )

  ;else

    (command "_.-BEDIT")

);if
  
(princ)
)

 I needed to include the bsave command prior to bclose, or else I would get an annoying notification when providing the "S" argument when there is no prompt to save an edited block.

0 Likes
Accepted solutions (1)
1,360 Views
8 Replies
Replies (8)
Message 2 of 9

pbejse
Mentor
Mentor
Accepted solution
(defun C:BB () ;Quick Block Entry
(if (= (getvar 'blockeditor) 1)
    (progn
	    (vl-cmdf "_.Bsave")
	    (vl-cmdf "_.Bclose")
      		(while (< 0 (getvar 'cmdactive)) (vl-cmdf "_S"))
      )
    (command "_.-BEDIT")

);if
  
(princ)
)
0 Likes
Message 3 of 9

martin_leiter
Advocate
Advocate

Hello pbejse,
that works very well. Would that also work for the "_.- REFEDIT" command? Tried but it didn't work.

0 Likes
Message 4 of 9

ВeekeeCZ
Consultant
Consultant

This?

 

(defun c:QRE () ;Quick Reference Edit
  (if (= "" (getvar 'refeditname))
    (if (ssget "_I")
      (command "_.-REFEDIT" "_Ok" "_All" "_No")
      (command "_.-REFEDIT" pause "_Ok" "_All" "_No"))
    (command "_.REFCLOSE" "_S"))
  (princ)
  )

 

 
0 Likes
Message 5 of 9

jon.t800
Contributor
Contributor

Hi pbejse,

 

Thanks for the showing an alternative solution which works as well. I was trying to see if anyone knew of the similar system variable to 'DBMOD', applicable to the block edit status.

0 Likes
Message 6 of 9

jon.t800
Contributor
Contributor

Hi ,

 

I just wanted to thank you for your original code snippet posted somewhere else for the -REFEDIT version. I added the additional in-ref-edit check to that.

 

Here was the code before I saw your post on this thread, inspired me to make some changes:

 

;; REFEDIT Macros
;; The "first"? time this macro is run, has to be through the dialog to specify locking of unrelated objects.
;; Possible that the user won't know this, lol.

(defun C:QE () ;Quick Block Edit
;gonna try and nest in a refclose + save if already in refedit mode
(if (/= (getvar 'refeditname) "")
    
    (vl-cmdf "_.Refclose" "S")

  ;else
  (if *refedit1st
    (command "_.-REFEDIT" "_Ok" "_All" "_No")
    (progn
      (setq *refedit1st T)
      (initdia)
      (command "_.REFEDIT"))
    )

);if
  
(princ)
)

 

 Context for the above additions, in case you might not remember: Using -refedit through the commandline doesn't allow the option to lock unrelated entities, so you added additional code to ensure the user steps through the usual refedit for the first time. I noticed that *refedit1st is set to true regardless of whether the user followed through with a successful refedit(by pressing ok instead of cancelling), so I have edited the set-true flag to occur only after the lisp checks and finds itself within a refedit. This would prevent user error unless the user deliberately unchecks the lock objects in the dialog box. I have no idea how to check for that, so that's the best I can get it to work.

 

Also, I see your new code has a new check for the implied selection, great idea to deal with the lisp not recognising a pre-selected block.

 

Here's the new version which I have adapted:

 

;; REFEDIT Macros
;; The "first"? time this macro is run, has to be through the dialog to specify locking of unrelated objects.
;; Possible that the user won't know this, lol.

(defun C:QE () ;Quick Block Edit
;gonna try and nest in a refclose + save if already in refedit mode
(if (/= (getvar 'refeditname) "")
    
    (vl-cmdf "_.Refclose" "S")

  ;else
  (if *refedit1st
    
  (progn
    (if (ssget "_I")
      (command "_.-REFEDIT" "_Ok" "_All" "_No")
      (command "_.-REFEDIT" pause "_Ok" "_All" "_No"))
     );progn

    (progn
      
      (initdia)
      (command "_.REFEDIT")
      (if (/= (getvar 'refeditname) "") (setq *refedit1st T))
     );progn
    
    );if

);if
  
(princ)
)

 

 Thanks for your help.

Message 7 of 9

martin_leiter
Advocate
Advocate

Hello jon.t800,
you solved that very well. I always had the problem that the objects that were not contained in the block were always moved along with the check mark at "Lock objects that are not in the workgroup"
Would you like to somehow bypass the "ok" click the first time so that you can immediately start editing the block?
If not it is not so bad because your Lisp helps me very well!

Many thanks!
Martin

0 Likes
Message 8 of 9

jon.t800
Contributor
Contributor

Hi Martin,

 

As much as I would have liked to bypass the initial "ok" click, it is my understanding that dialog boxes "freeze" the running of the program and there is no way to write a command to press that "ok" automatically. So once the "ok" is pressed or "cancel" or "x", the dialog box closes and the program immediately resumes running.

 

On the off-chance anyone knows it's actually possible, please share.

0 Likes
Message 9 of 9

martin_leiter
Advocate
Advocate

Hello, thanks for your great help!

0 Likes