Author Topic: if statement for menus  (Read 3993 times)

0 Members and 1 Guest are viewing this topic.

pmvliet

  • Guest
if statement for menus
« on: January 26, 2005, 03:59:03 PM »
I have the following code to load a partial menu
Code: [Select]


(command "menuload"
"i:\\AutoDesk\\SSOE\\AutoCad\\menu\\SSOE"
)
(menucmd "p14=+ssoe.pop1")


The problem that I am running into is that once I get out of AutoCad and back in, the menu is already loaded. How do I go about turning this into a if statement to check if it is loaded and if it is, go on?

I will have more ?'s but this will be the first.

Pieter

Mark

  • Custom Title
  • Seagull
  • Posts: 28762
if statement for menus
« Reply #1 on: January 26, 2005, 04:01:07 PM »
How about the menugroup function??
TheSwamp.org  (serving the CAD community since 2003)

pmvliet

  • Guest
if statement for menus
« Reply #2 on: January 26, 2005, 04:06:50 PM »
I will have to see how that works.
I will try something and post back.

Thanks,
Pieter

pmvliet

  • Guest
if statement for menus
« Reply #3 on: January 26, 2005, 04:39:09 PM »
ok I need a teaser.
help file tells me that a menu group is defined as

Quote
(menugroup groupname)


My group name is SSOE but it is located @
"i:\\AutoDesk\\SSOE\\AutoCad\\menu\\SSOE

Will menugroup load the menu or do I still need the menucmd?

pmvliet

  • Guest
if statement for menus
« Reply #4 on: January 27, 2005, 02:36:57 PM »
(menugroup "ssoe") returns nil if that menu is not loaded.
(menugroup "ssoe") returns "ssoe" if the menu is loaded.

The beginning of my code will check  if I get "nil" or "ssoe".
If it returns "nil" I will then want to load that menu with
Code: [Select]
(command "menuload"
    "i:\\AutoDesk\\SSOE\\AutoCad\\menu\\SSOE"
)
(menucmd "p14=+ssoe.pop1")


If it returns "ssoe" I want it to go on.
Do I want the answers to be set to a variable so that it can be compared with a "if" statement of something like that?

This is hurting my brain... It is worth it though..

Pieter

Mark

  • Custom Title
  • Seagull
  • Posts: 28762
if statement for menus
« Reply #5 on: January 27, 2005, 02:57:17 PM »
Sorry Pieter I forgot all about ya......... :roll:

try this
Code: [Select]

;; if 'menugroup' comes back nil then load it
;; other wise move on........
(if (not (menugroup "ssoe"))
  (progn
    (command "menuload" "i:\\AutoDesk\\SSOE\\AutoCad\\menu\\SSOE")
    (menucmd "p14=+ssoe.pop1")
    )
  )
TheSwamp.org  (serving the CAD community since 2003)

pmvliet

  • Guest
if statement for menus
« Reply #6 on: January 27, 2005, 03:54:17 PM »
Ok, that works great!.
Just so I understand, (if start's the if function.
(not is telling the if statement that if the answer coming back from
"menugroup" is not equal to itself, go on and do progn.
You need progn because we are doing two things.
1 is loading the menu, then second item is then setting the pull down menu.

Ok, another obstacle.
In AutoCad there is the variable,
Code: [Select]
(Setenv
 "MenuFile"
  "I:\\autodesk\\ssoe\\autocad\\menu\\acad"
)

I want to pull the Acad.mnu from a network location and not the individual pc's. Would this be the best way to set this? or would it be best to just do it the same way. I tried it both ways and the "MenuFile" way doesn't seem to work very good.

So I am loading it
Code: [Select]

;;;Load the Acad Menu from the I:drive
(if (not (menugroup "acad"))
  (progn
    (command "menuload" "i:\\AutoDesk\\SSOE\\AutoCad\\menu\\acad.mnu")
       )
  )


Would I run into any problems?

ronjonp

  • Needs a day job
  • Posts: 7529
if statement for menus
« Reply #7 on: January 27, 2005, 04:27:58 PM »
Mark I used your code to load my menu but my pulldown menu does not get placed on the menu bar??

Thanks,

Ron

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

pmvliet

  • Guest
if statement for menus
« Reply #8 on: January 27, 2005, 05:02:13 PM »
What did you change this line to be?
Code: [Select]
(menucmd "p14=+ssoe.pop1")
you would want to change ssoe to be your menugroup name
and you would need pop1 defined in this menu.
it then should place it in slot 14 accross your pulldowns.

ronjonp

  • Needs a day job
  • Posts: 7529
if statement for menus
« Reply #9 on: January 27, 2005, 05:07:18 PM »
This is what I have...maybe the + in the name is screwing it up?  

Code: [Select]
;; if 'menugroup' comes back nil then load it
;; other wise move on........
(if (not (menugroup "AQUA2004+"))
  (progn
    (command "menuload" "C:\\Program Files\\AutoCAD Tools\\AQUA2004+")
    (menucmd "p20=+AQUA2004+.pop1")
    )
  )
(princ)

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

pmvliet

  • Guest
if statement for menus
« Reply #10 on: January 27, 2005, 05:08:55 PM »
Moving forward, I want to load employee menu's. Each employee has a home directory on the server that is going to have their personal menu.
I would like to autoload their personal menu into AutoCad when they start autocad.

Code: [Select]
;;;Load Employee menu from F:drive
(if (not (menugroup (strcat (getenv "username")))
  (progn
    (command "menuload" "f:\\Autocad\\(strcat (getenv "username"))")
    (menucmd "p16=+(strcat (getenv "username"))).pop1")
  )
)


the line
Code: [Select]
(menugroup (strcat (getenv "username")))
works and brings back either nil or their employee number.
"username" is an environment variable.

I can't seem to get
Code: [Select]

(command "menuload" "f:\\Autocad\\(strcat (getenv "username"))")

to work.  I am probably just missing something simple with a typo/formatting...

Pieter

pmvliet

  • Guest
if statement for menus
« Reply #11 on: January 27, 2005, 05:11:22 PM »
I would say the + on the end is messing with the loading of your menu.
You can change that inside the menu so you don't have the change the actual file name.
***Menugroup=Aqua2004
instead of
***Menugroup=Aqua2004+

I would tihnk that is what you have...

Pieter

ronjonp

  • Needs a day job
  • Posts: 7529
if statement for menus
« Reply #12 on: January 27, 2005, 06:33:20 PM »
Maybe.....

Code: [Select]
(command "menuload" (strcat "f:/Autocad/" (getenv "username")))

Ron

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

pmvliet

  • Guest
if statement for menus
« Reply #13 on: January 28, 2005, 10:32:36 AM »
Thanks Ron!

I knew it was going to be something simple like a typo. At least I think that is what it is... Those pesky "'s...

did you get your menu to load?