Author Topic: CAD Setup Routine  (Read 61692 times)

0 Members and 1 Guest are viewing this topic.

amgirard2003

  • Guest
CAD Setup Routine
« Reply #30 on: January 26, 2004, 08:28:18 AM »
Morning Guys,

Well here's a small update
I downloaded the DCL manual off afralisp and made a simple
login dialog box.

Code: [Select]

login : dialog {
label = "Login" ;



        : edit_box {
 key = "login" ;
 label = "Enter your Name" ;
 mnemonic = "N" ;
 alignment = centered ;
 edit_width = 10 ;
 edit_limit = 10 ;
}

: row {

: button {
key = "accept" ;
label = "Ok" ;
mnemonic = "O" ;
is_default = true ;
width = 12 ;
alignment = centered ;
}

: button {
key = "cancel" ;
label = "Cancel" ;
mnemonic = "C" ;
is_default = true ;
width = 12 ;
alignment = centered ;
}
}
}


Lisp Code
Code: [Select]

(defun c:startup ()
  (setq log_dlg (load_dialog "login.dcl"))
  (if (not (new_dialog "login" log_dlg)
  )
    (exit)
    )

  (action_tile "cancel"
    "(done_dialog) (setq userclick nil)"
    )

  (action_tile "accept"
    "(done_dialog) (setq userclick T)"
    )

  (start_dialog)

  (unload_dialog log_dlg)

  (princ)
  )
(princ)

My plan is when the user enters a login name
the dialog box will disappear and a new dialog box will appear
I'm working on the next dialog box next.

I would appreciate any constructive criticism.

Thanks

amgirard2003

  • Guest
CAD Setup Routine
« Reply #31 on: January 26, 2004, 09:29:20 AM »
Here's the next box

It's still a work in progress,

Code: [Select]

setup : dialog {
label = "Page Setup" ;

: row {

: boxed_radio_column {
label = "Drawing Type" ;

: radio_button {
label = "Construction" ;
key = "rb1" ;
value = 1 ;
}

: radio_button {
label = "Conversion" ;
key = "rb2" ;
}

: radio_button {
label = "Primary" ;
key = "rb3" ;
}

: radio_button {
label = "Second/Street" ;
key = "rb4" ;
}

} // end of Drawing Type radio_boxed_column


: boxed_radio_column {
label = "Size" ;

: row {

: radio_button {
label = "A = 9 x 12in" ;
key = "rb5" ;
value = 1 ;
}

:radio_button {
label = "B = 12 x 18in" ;
key = "rb6" ;
}
} // end of Sheet Row A & B

: row {

: radio_button {
label = "C = 18 x 24in" ;
key = "rb7" ;
}

: radio_button {
label = "D = 24 x 36in" ;
key = "rb8" ;
}
} // end of sheet C & D row

: row {

: radio_button {
label = "Custom" ;
key = "rb9" ;
}

: edit_box {
label = "W" ;
key = "w" ;
}

: edit_box {
label = "H" ;
key = "h" ;
}
} // end of Custom sheet row

} // end of sheet size boxed_radio_column
} // end of row

: row {

: toggle {
label = "Metric" ;
key = "togmet" ;
width = 5 ;
}

: toggle {
label = "Imperial" ;
key = "togimp" ;
width = 5 ;
}

: edit_box {
label = "Scale:" ;
key = "scale" ;
width = 5 ;
}
} // end of toggle & scale row

: row {

: button {
label = "Ok" ;
key = "accept" ;
mnemonic = "O" ;
width = 12 ;
is_default = true ;
}

: button {
label = "Cancel" ;
key = "cancel" ;
mnemonic = "C" ;
width = 12 ;
}

: button {
label = "Help" ;
key = "help" ;
mnemonic = "H" ;
width = 12 ;
}
} // end of button row
} // end of dialog

daron

  • Guest
CAD Setup Routine
« Reply #32 on: January 26, 2004, 09:43:31 AM »
You don't need a login dialog if you and your user login when you start your computer. All you have to do is know what their usernames are and use this:
Code: [Select]
(setq uname (getvar 'loginname))
That way all your coding can be done to suit their workstations, wherever they may be without them even knowing it or being bothered by a dialog box at all. Good practice with dcl.

deegeecees

  • Guest
CAD Setup Routine
« Reply #33 on: January 26, 2004, 10:08:13 AM »
Am-2003, if you are looking to get a name for each user rather than a login ID (i.e. PD7534), you could set a variable to a string that corresponds with the actual login such as:

(setq log_ID (getvar "loginname"))
(setq log_name
   (cond
      ((= log_ID "SD0034") "Sally")
      ((= log_ID "RC0045") "Rotten")
      ((= log_ID "YK0067") "Crotch")
   )
)

This way you automatically pick up the user login and associate it with a real name (or as in this case a made up one :twisted: ).

amgirard2003

  • Guest
CAD Setup Routine
« Reply #34 on: January 26, 2004, 10:30:33 AM »
O.k... i've been banging my head on this and can't figure it our
cause i don't know where to begin..

I don't know how to apply this:
Code: [Select]

(setq log_ID (getvar "loginname"))
(setq log_name
(cond
((= log_ID "amgirard") "Andre")
)
)


to this:

Code: [Select]

(defun c:startup ()
  (setq set_dlg (load_dialog "setup.dcl"))
  (if (not (new_dialog "setup" set_dlg)
  )
    (exit)
    )

  (action_tile "cancel"
    "(done_dialog) (setq userclick nil)"
    )

  (action_tile "accept"
    "(done_dialog) (setq userclick T)"
    )

  (start_dialog)

  (unload_dialog set_dlg)

  (princ)
  )
(princ)



my weakness is not understanding how to combine code to make it work..
What i want is if the loginname doesn't match, it will prompt the user they have no rights to the setup routine. If the username matches it will load the setup dialog..

I'm lost  :?

Thanks,

deegeecees

  • Guest
CAD Setup Routine
« Reply #35 on: January 26, 2004, 10:49:54 AM »
The point is that you don't need a dialog box for any of that. Its all done autmatically. But, just for $hits and giggles, put the statement in the "accept" portion of the dialog box code:

(action_tile "accept"
    "(done_dialog) (setq userclick T)"
         (setq log_ID (getvar "loginname"))
         (setq log_name
             (cond
                ((= log_ID "amgirard") "Andre")
             )
         )
)

and then type      !log_name        at the command prompt

SMadsen

  • Guest
CAD Setup Routine
« Reply #36 on: January 26, 2004, 10:53:07 AM »
Code: [Select]
(if (member log_name (list "Andre" "Susan" "Anthony"))
  (C:STARTUP)  ; ok, go!
  (alert "You're are not special enough!") ; nope, don't go any further!
)


This takes the log_name variable and sees if it is member of the list of legal users.

deegeecees

  • Guest
CAD Setup Routine
« Reply #37 on: January 26, 2004, 11:01:27 AM »
Ooops, I didn't read your post all the way through  :(  , SMadsen has the answer for you. This will be invisible to the user.

Stig, It's like the blind leading the blind here, I aint got my CAD puter in front of me and when confronted with questions such as these I feel nekked. I'm running on pure mem power and there ain't much of that to start with. :D

daron

  • Guest
CAD Setup Routine
« Reply #38 on: January 26, 2004, 11:13:18 AM »
Sit back, take a deep breath and let's think of something new. Exhale. Breath normal. Ready. Okay, Let's not lock users out, but instead, let's give them control based on their needs and username. Here's a simple function that I use to set the command value of zx differently for me than anybody else using the same function.
Code: [Select]
(defun c:zx ()
     (if (= (strcase (getvar "loginname") t) "drogers")
 (command ".zoom" "")
 (command ".zoom" ".9X")
     )
     (princ)
)

You'll notice in the command above I have my username set as the true case. So, the way it reads is (if (users loginname converted to lowercase)= the string "drogers" then use real time zoom, otherwise, use zoom scale .9x).

Zoom .9x is something my users wanted to use, but I find the rtzoom more to my liking. This was my solution. The cond statement is the same way, except you need to know all the other usernames included and you'll have to update your code with the advent of new hires and username changes. These are just some things to consider. If you have a high employee turnover rate, your original idea might be what you're after afterall, although, your users might not like to type in their name everytime they open autocad. Most of them might just hit escape and there go all your standards. Autocad will continue on regardless. One more thing to consider is limit your user interaction. This may seem dictatorial, but what they don't know won't hurt them, in this case and you can give them flexibility by finding out how they like to work and adjust your standards for how they like to work. I don't know anybody who likes to be told how to to the job. Give them the tools to do the job i.e. layers, but give them the flexiblity to add a toolbar or change the color of their command panel. I personally use a blue background with a cyan text. It feels like the ocean to me and keeps me relaxed. another guy here likes black background with white text. I'm sure he has his reasons. What I'm getting at is, your users are individuals who react to situations in different ways. Let them decide what they like to see and how they like to use autocad. You set up the standards that should be adhered to behind the scenes and you should be able to create a good, productive working atmosphere. I too like Stig's answer as far as code goes, but consider what is best for you and your team.

amgirard2003

  • Guest
CAD Setup Routine
« Reply #39 on: January 26, 2004, 11:14:23 AM »
I'm goin dumb understanding what everyone is sayin

I'm lost... am i incorporating this:

Code: [Select]

(action_tile "accept"
"(done_dialog) (setq userclick T)"
(setq log_ID (getvar "loginname"))
(setq log_name
(cond
((= log_ID "amgirard") "Andre")
)
)
)


with this:

Code: [Select]

(if (member log_name (list "Andre" "Susan" "Anthony"))
  (C:STARTUP)  ; ok, go!
  (alert "You're are not special enough!") ; nope, don't go any further!
)



completely lost :? :?

amgirard2003

  • Guest
CAD Setup Routine
« Reply #40 on: January 26, 2004, 12:45:22 PM »
well i'll try and figure this out..

deegeecees

  • Guest
CAD Setup Routine
« Reply #41 on: January 26, 2004, 12:54:35 PM »
I'll try to decipher the preceding posts for you Am2003:

Code: [Select]
(defun c:zx ()
     (if (= (strcase (getvar "loginname") t) "drogers")
     (command ".zoom" "")
     (command ".zoom" ".9X")
     )
     (princ)
)


This is just a "function" that could reside in the acad2000doc.lsp that we created. You could call this up from the command line or a button, or a pull down menu selection. The (command ".zoom" "") is what happens when Lisp finds "drogers" as the login name. The (command ".zoom" ".9x") is what happens when someone else is logged in. It all happens with the IF statement. So, IF the LOGINNAME = (equals) DROGERS, then (command ".zoom" ""), otherwise (command ".zoom" ".9x"). The strcase just capitalizes all the letters found in each login.

Are you with me so far?

daron

  • Guest
CAD Setup Routine
« Reply #42 on: January 26, 2004, 12:56:24 PM »
I thought I did that with my code. What's with copying that?

amgirard2003

  • Guest
CAD Setup Routine
« Reply #43 on: January 26, 2004, 01:21:38 PM »
yeah i'm with you on that one..
The part that i'm confused with is this

How do i apply this:

Code: [Select]

(setq log_ID (getvar "loginname"))
(setq log_name
(cond
((= log_ID "amgirard") "Andre")
)
)


To this:

Code: [Select]

(defun c:startup ()
  (setq set_dlg (load_dialog "setup.dcl"))
  (if (not (new_dialog "setup" set_dlg)
      )
    (exit)
    )

  (action_tile "cancel"
    "(done_dialog) (setq userclick nil)"
    )

  (action_tile "accept"
    "(done_dialog) (setq userclick T)"
    )

  (start_dialog)

  (unload_dialog set_dlg)

  (princ)
  )
(princ)


I don't know how to put these 2 parts of code together...
I'm a newbie and reading and putting code together is still a challenge..
I get more confused when "one liners" are posted...  i never know what too do with it, where to put it in my code, what do i take out of my code for it to work?  Those are things that go through my mind and i don't know how to answer those questions and what the possible solutions could be..

I know you'll all be asking why start with a big project like this..
If i can get a broader view of LISP i think it will help me learn more about it.
Not just little pieces at a time...

amgirard2003

  • Guest
CAD Setup Routine
« Reply #44 on: January 26, 2004, 01:27:30 PM »
Question

Code: [Select]

(defun c:zx ()
     (if (= (strcase (getvar "loginname") t) "drogers")
     (command ".zoom" "") ; line 1
     (command ".zoom" ".9X") ; line 2
     )
     (princ)
)


I understand the concept of this code... that's not a problem..
When further looking at this code somethin didn't make sense

IF LOGINNAME = DROGERS then ZOOM
IF NOT = DROGERS then ZOOM 9X

how does the if know which one to pick... i don't see a pointer telling it which one to pick depending on the loginname