Locking the Z value?

At some point in the past, I think I found a utility that will allow me to lock the Z value to 0.  I say "I think" because I see that I created a menu button with "lock Z" as its title.  But, the actual macro is not there.  Perhaps I started on it, and didn't successfully get it to work.

I have searched the BricsCAD help for "Lock" and "Z" but nothing showed up that was appropriate.  

Can anyone recommend a utility that can do this, or refer me to the proper terminology in BricsCAD if the feature already exists?

-Joe

Comments

  •  Have a look at the OSNAPZ command.
  • Note: The OSNAPZ variable is not stored. When you restart BC it will always be OFF. Use on_start.lsp to change this is required.
  • Thank you Mr. Gebbinck.  That was exactly what I was looking for, but didn't know the right terminology to find.  I could not find any existing toolbar that had a toggle for that. But with the right terminology, I found some code to put into the command part of a custom toolbar. 

    osnapz $M=$(-,1,$(getvar,osnapz))

    Also, attached is the image I used for the button.

    -Joe
    imageLock-Z.bmp
  • Please notice that a toolbutton in the Entity Snaps toolbar has been added to toggle the value of the OSNAPZ system variable. The state of the toolbutton (pressed or not) reflects the current value of OSNAPZ.
  • Since my version 14 doees not have the OsnapZ button available, I want to create a button that changes its appearance, depending on the value of OsnapZ.  Does anyone know how that is accomplished?

    Note that I did find another possible compromise, from AllenJessup in the Autodesk forums.  His solution was to have the Diesel command line show the value on the command line when ever it is toggled;
    (setvar "OSNAPZ" (if (= (getvar "OSNAPZ") 1)0 1))(princ (strcat "Replace Z value is now turned " (if (= (getvar "OSNAPZ") 1)"ON""OFF")))(princ)

    But, I would still like to find a way to make the button's appearance change to show it is toggled on.  Is this possible?

    -Joe


  • Joe,

    Look at any of the toolbar buttons on the esnap toolbar.  For example, the center esnap button status is toggled using
    [code]$(if,$(=,$(and,$(getvar,OSMODE),0x0004),0),,!.)[/code]
    on the DIESEL line of the button description.  The key part is the    ,,!.   at the end.
  •  I am not having any luck with that.  I don't actually understand how the command is functioning, but imagine the "and" function is one way to toggle a 0/1 value. If I change the OSMODE to OsnapZ, it does not change the OsnapZ value, nor does it change the appearance of the button.  I also tried appending the ,,!. inside the last parenthesis.  I looked at the developer reference, but I cannot find any reference to a command to change the appearance of a button.

    Perhaps that ,,!. process does not work on the OsnapZ command?

    -Joe
  • 0x0004 equals 4. OsnapZ can only have two values 0 or 1. Try using 0x0001 or just 1 should also work.
  •  Thanks for participating in the discussion, but I am afraid that changing the 0x0004 to 0x0001 did not solve the problem.

    To be certain I am clear, this is what I just tried without success.
    $(if,$(=,$(and,$(getvar,OSMODE),0x0001),0),,!.)

    -Joe

  • Upgrade to V15/V16, this will include the updated menu :-)

    To setup Osnapz in the CUI
    Command: '_setvar;OSNAPZ;$M=$(if,$(=,0,$(getvar,OSNAPZ)),1,0)
    Diesel: $(if,$(=,$(getvar,OSNAPZ),0),,!.)

    The command portion you've mentioned in post 5 is LISP not Diesel. Should work the same.
    The shadow highlighting of toolbar icons can be rather subtle. You could try using a different button image to see whether it improves visibility.

    Regards, Jason Bourhill CAD Concepts 
  • Joe,

    I suggest looking at the definitions for the esnap toolbar in the CUI editor for your version.  Attached is what I see for OsnapZ in V15.
    imagez.PNG
  • I see now that I was putting the wrong command in the command line, and ignoring the Diesel line in the CUI editor.  

    However, there is still an odd behavior.  The button appearance does not change right away. Rather, after I do something like create a line or circle, then the button will change its display state.

    It may be that I was confused in my prior attempts by this delayed toggle.

    Thank you all for sticking with me on this.  I am satisfied with the current behavior even if it is not ideal.

    -Joe


  • In V14 there is indeed a delayed response.
    Here is a Lips function to fix this.
    [code]; Toolbar Diesel:  $(if,$(=,$(getvar,OSNAPZ),0),,!.)
    ; Toolbar Command: ToggleOsnapZ
    (defun c:ToggleOsnapZ ()
      (setvar 'osnapz (boole 6 (getvar 'osnapz) 1))
      (setvar 'cmdecho 0)
      (acet-acad-refresh) ; Calls the _ZOOM command twice.
      (setvar 'cmdecho 1)
      (princ)
    )[/code]
This discussion has been closed.