Button to change osnaps during lisp command

Button to change osnaps during lisp command

Anonymous
Not applicable
1,091 Views
4 Replies
Message 1 of 5

Button to change osnaps during lisp command

Anonymous
Not applicable

With the freezing temperatures today, I'm having a brain freeze.

 

For each user, I store an osmode number to variable User_Osnap_Number

 

In the menu I have a button with the following -

'setvar osmode !User_Osnap_Numer

 

If the user is running an AutoCAD command, selecting the button sets the osnap

 

If they are running an AutoLISP command, selecting the button does the following -

 

Pick INSERTION Point for 'NAC' device ? 'setvar >>Enter variable name or [?] <OSMODE>: osmode
>>Enter new value for OSMODE <16483>: !user_osnaps_Number
Requires an integer between 0 and 32767.
>>Enter new value for OSMODE <16483>: *Cancel*

Resuming IB command.

 

But doesn't change the osmode value

 

0 Likes
1,092 Views
4 Replies
Replies (4)
Message 2 of 5

Kent1Cooper
Consultant
Consultant

@Anonymous wrote:

.... 

For each user, I store an osmode number to variable User_Osnap_Number

In the menu I have a button with the following -

'setvar osmode !User_Osnap_Numer

.... 

Pick INSERTION Point for 'NAC' device ? 'setvar >>Enter variable name or [?] <OSMODE>: osmode
>>Enter new value for OSMODE <16483>: !user_osnaps_Number
Requires an integer between 0 and 32767.


Are you misspelling it somewhere?  The variable names don't agree.

Kent Cooper, AIA
0 Likes
Message 3 of 5

Moshe-A
Mentor
Mentor

Hi,

 

i  do not see where variable User_Osnap_Number is set. the error says the value in the variable is not an integer

maybe it is still nil?

 

Moshe

 

0 Likes
Message 4 of 5

scot-65
Advisor
Advisor
Numer
and
osnaps
are not consistent throughout.

I'm not sure what it is you are trying to do?
Are you allowing each user to store, then later retrieve their "magic number"?
If so, then use the registry to store/retrieve such variable.

I'm not sure which version of AutoCAD they finally switched from
a stored value in the drawing to a stored user setting, but it does
wonders now.

For program flow, allow the user to keep his/her OSMODE setting
during the selection/specifying process. If one is required, then
one will also have to write an error handler to reset. Otherwise add
16384 to the current value to suppress while the "main" program is
generating entities (via command-s...). If the "main" part of the
program fails, the user can simply turn back on the OSMODE value
by selecting the icon in the status bar.

One trick I discovered is to check 16384 both at the beginning
and end of the main execution section. When testing programs
under development, it auto-corrects itself when the program
first fails, then on the next run it is working...

;set:
(if (< (getvar "OSMODE") 16384) (setvar "OSMODE" (+ (getvar "OSMODE") 16384)))
;reset and inside *error*:
(if (> (getvar "OSMODE") 16384) (setvar "OSMODE" (- (getvar "OSMODE") 16384)))

???

Scot-65
A gift of extraordinary Common Sense does not require an Acronym Suffix to be added to my given name.

0 Likes
Message 5 of 5

Anonymous
Not applicable

Try making a (defun c:47 () (setvar 'osmode 47)) which is setting the osmode to 47.

 

If you do say Line pickpt '47 then it has changed the osmode using the option of transparent command within a command.

 

Try another like m2p. A little used but very powerful is 'cal this opens the autocad calculator function in the middle of a command. Check help 'cal there are a lot of inbuilt functions.

0 Likes