Author Topic: Setting the OSMODE Setting  (Read 4299 times)

0 Members and 1 Guest are viewing this topic.

laison

  • Guest
Setting the OSMODE Setting
« on: November 08, 2010, 10:21:29 PM »
When writing code and you get to where you are going to set you OSMODE setting can you set more than 1 setting in the same line?

Code: [Select]
(setvar "osmode" 1, 2, 4, 32)
[CODE]
[/code]

alanjt

  • Needs a day job
  • Posts: 5352
  • Standby for witty remark...
Re: Setting the OSMODE Setting
« Reply #1 on: November 08, 2010, 10:42:05 PM »
You add them.
eg.
Code: [Select]
(setvar 'osmode (+ 1 2 4 32)) or
Code: [Select]
(setvar 'osmode 39)
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: Setting the OSMODE Setting
« Reply #2 on: November 08, 2010, 10:54:17 PM »
Given it's a bit coded integer I'd be more inclined to "or" the values together:

(setvar "osmode" (logior + 1 2 4 32))

I tried to rewrite this 3 times so I wouldn't sound like a dick without success; sorry, just sayin'.

shrug_icon_goes_here
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

alanjt

  • Needs a day job
  • Posts: 5352
  • Standby for witty remark...
Re: Setting the OSMODE Setting
« Reply #3 on: November 08, 2010, 11:18:46 PM »
No dick, just educating.
Thanks Michael.

I assume you meant: (logior 1 2 4 32)
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: Setting the OSMODE Setting
« Reply #4 on: November 08, 2010, 11:26:11 PM »
yeah sh!t :lol: thanks for being gracious

I'll leave the error so the thread makes sense
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

David Bethel

  • Swamp Rat
  • Posts: 656
Re: Setting the OSMODE Setting
« Reply #5 on: November 09, 2010, 06:18:35 AM »
logior makes more sense to me if you your trying to ensure that the new modes were added to the existing osmode setting.

Code: [Select]

(setq os (getvar "OSMODE"))

(setvar "OSMODE" (logior os 1 2 4 32))


It adds the bit regardless of the current setting. 

I think I would stick with the plus just for readability. -David

R12 Dos - A2K

Daniel J. Ellis

  • Swamp Rat
  • Posts: 811
Re: Setting the OSMODE Setting
« Reply #6 on: November 09, 2010, 08:07:50 AM »
So what  does logior do?

dJE
===
dJE

JohnK

  • Administrator
  • Seagull
  • Posts: 10626
Re: Setting the OSMODE Setting
« Reply #7 on: November 09, 2010, 08:28:06 AM »
...
I'll leave the error so the thread makes sense

heh, too bad some people dont share that basic courtesy.
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

David Bethel

  • Swamp Rat
  • Posts: 656
Re: Setting the OSMODE Setting
« Reply #8 on: November 09, 2010, 08:45:27 AM »
Lets say you want to close a polyline : set the 1 bit in the group 70 flag

Code: [Select]
(setq flag (cdr (assoc 70 ed)))

Either of these statements work:

Code: [Select]
(if (/= (logand flag 1) 1)
    (setq flag (+ flag 1)))

(logior flag 1)

Logior's advantage is that accepts multiple tests in a single call.

-David
R12 Dos - A2K