Author Topic: Newbie to world of (Lost in Stupid Parentheses) errr..(List)  (Read 101425 times)

0 Members and 2 Guests are viewing this topic.

daron

  • Guest
Newbie to world of (Lost in Stupid Parentheses) errr..(List)
« Reply #285 on: November 19, 2003, 11:19:54 AM »
What do you get?

amgirard2003

  • Guest
Newbie to world of (Lost in Stupid Parentheses) errr..(List)
« Reply #286 on: November 19, 2003, 11:25:12 AM »
it seems to be acting like the "enter" key...
i get nil after i click the right button

SMadsen

  • Guest
Newbie to world of (Lost in Stupid Parentheses) errr..(List)
« Reply #287 on: November 19, 2003, 11:32:52 AM »
Hmmm .. dunno what setting is stealing away the popup menu if not the ones Daron mentioned.
Anyway, in normal setup's this is why you see all those commands having a list of choices formatted like [option1/option2/...]

Even a command like OFFSET that only has one option, Through, offers it in square brackets so that the user can choose it in a right-click popup.

daron

  • Guest
Newbie to world of (Lost in Stupid Parentheses) errr..(List)
« Reply #288 on: November 19, 2003, 12:33:00 PM »
Back on track: Have you gotten your function working yet?

amgirard2003

  • Guest
Newbie to world of (Lost in Stupid Parentheses) errr..(List)
« Reply #289 on: November 19, 2003, 12:52:33 PM »
Yeah let's get back on track here..
Well working on it slowly here..

Got a question..
I have a lintype that is not loaded.

1) how do i write the code to load a linetype?
2) what is the variable to change the scale of a particular line?
i don't want to do it globally

daron

  • Guest
Newbie to world of (Lost in Stupid Parentheses) errr..(List)
« Reply #290 on: November 19, 2003, 01:01:23 PM »
Have a looksy here. You might read/skim the entire topic.

amgirard2003

  • Guest
Newbie to world of (Lost in Stupid Parentheses) errr..(List)
« Reply #291 on: November 19, 2003, 01:20:33 PM »
That's one hell of an example... it's flown over my head but i figured out how to load the linetype i was lookin for

daron

  • Guest
Newbie to world of (Lost in Stupid Parentheses) errr..(List)
« Reply #292 on: November 19, 2003, 01:23:29 PM »
Good. What's next? Post your writings and I/we'll show you how to make a reusable function of it, like I was talking earlier.

amgirard2003

  • Guest
Newbie to world of (Lost in Stupid Parentheses) errr..(List)
« Reply #293 on: November 19, 2003, 02:04:13 PM »
o.k here's what i got...
Please take it easy on me i know you guys can rip it up pretty good..

(defun c:nl ()
(prompt "Run with Phil's routine only")
(initget 0 "T D S C E F")
  (setq ans
    (getkword "\nSelect Line [Three/Double/Single/seCondary/(E)600/(F)208]: <> ")
  )


(cond ((= ans "T")   
   (setvar "clayer" "612")
   (setvar "celtype" "Three"))
)

(cond((= ans "D")                
 (setvar "clayer" "612")
 (setvar "celtype" "Double"))
)

(cond ((= ans "S")
  (setvar "clayer" "612")
  (setvar "celtype" "Single"))
   
)

(cond ((= ans "C")
  (setvar "clayer" "622")
  (setvar "celtype" "Bylayer")
  (setvar "plinewid" 0.5))
)

(cond ((= ans "E")
  (setvar "clayer" "622")
  (setvar "celtype" "Hidden")
  (setvar "ltscale" 0.5))
)

(cond ((= ans "F")
  (setvar "clayer" "622")
  (command "linetype" "l" "*" "conversion.lin" ""))
  )
(princ)
)

How do i make it so when i start the pline command ( not to that point yet )
the polylines are lwpolylines?

How do i set ltscale of a particular line? i don't want to do it globally

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Newbie to world of (Lost in Stupid Parentheses) errr..(List)
« Reply #294 on: November 20, 2003, 03:34:06 AM »
Quote from: amgirard2003
it seems to be acting like the "enter" key...
i get nil after i click the right button


What is the value of your SHORTCUTMENU System Variable ??

 .. Try 11 .. check the Help file for info.

Do not 'click" the right mouse button .. try a long PRESS { hold it down & count to 1.2 }

Regards

.. now we switch back to your scheduled programme ..
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Newbie to world of (Lost in Stupid Parentheses) errr..(List)
« Reply #295 on: November 20, 2003, 03:46:04 AM »
Regarding the COND  function :-
It may help to think of it as ;

do either
this
or this
or this ...

.. and your revised code will look something like this :-
Code: [Select]

(defun c:nl (/ ans)
  (prompt "Run with Phil's routine only")
  (initget 0 "Three Double Single seCondary E E600 F F208")
  (setq ans
         (getkword
           "\nSelect Line [Three/Double/Single/seCondary/E600/F208] : "
         )
  )
  (cond ((= ans "T")
         (setvar "clayer" "612")
         (setvar "celtype" "Three")
        )
        ((= ans "D")
         (setvar "clayer" "612")
         (setvar "celtype" "Double")
        )
        ((= ans "S")
         (setvar "clayer" "612")
         (setvar "celtype" "Single")
        )
        ((= ans "C")
         (setvar "clayer" "622")
         (setvar "celtype" "Bylayer")
         (setvar "plinewid" 0.5)
        )
        ((= ans "E")
         (setvar "clayer" "622")
         (setvar "celtype" "Hidden")
         (setvar "ltscale" 0.5)
        )
        ((= ans "F")
         (setvar "clayer" "622")
         (command "linetype" "l" "*" "conversion.lin" "")
        )
  )
  (princ)
)
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

daron

  • Guest
Newbie to world of (Lost in Stupid Parentheses) errr..(List)
« Reply #296 on: November 20, 2003, 09:55:20 AM »
And to take what Kerry gave you, I'll show you what I meant by creating a reusable function. The function at the bottom is what is doing the work. The portion at the beginning of the main routine is there to use the current variables values for the required arguments in the reusable function. Thus, the use of (cdr (nth num n)) in place of setting a variable (setvar).
Code: [Select]
(defun c:nl (/ ans var n)

  (setq var '("clayer" "celtype" "ltscale" "plinewid")
n   nil
  )
  (foreach item var
    (setq n (append n (list (cons item (getvar item)))))
  )

  (prompt "Run with Phil's routine only")
  (initget 0 "Three Double Single seCondary E E600 F F208")
  (setq ans
(getkword
  "\nSelect Line [Three/Double/Single/seCondary/E600/F208] : "
)
  )
  (cond ((= ans "T")
(chvars "612" "Three" (cdr (nth 2 n)) (cdr (nth 3 n)))
)
((= ans "D")
(chvars "612" "Double" (cdr (nth 2 n)) (cdr (nth 3 n)))
)
((= ans "S")
(chvars "612" "Single" (cdr (nth 3 n)))
)
((= ans "C")
(chvars "622" "Bylayer" (cdr (nth 2 n)) 0.5)
)
((= ans "E")
(chvars "622" "Hidden" 0.5 (cdr (nth 3 n)))
)
((= ans "F")
(chvars "622"
(cdr (nth 1 n))
(cdr (nth 2 n))
(cdr (nth 3 n))
)
(command "linetype" "l" "*" "conversion.lin" "")
)
  )
  (princ n)
  (princ)
)

(defun chvars (clay lintype lscale plwid)
  (setvar 'clayer clay)
  (setvar 'celtype lintype)
  (setvar 'ltscale lscale)
  (setvar 'plinewid plwid)
)

amgirard2003

  • Guest
Newbie to world of (Lost in Stupid Parentheses) errr..(List)
« Reply #297 on: November 20, 2003, 10:37:44 AM »
Daron can u fully explain what you just did cause that flew by me the speed of light...i'm not getting anything of what you just wrote.

1) How does it know what linetype to set if you didn't assign it the way i did in my example.
2) and the same for plinewidth and linetype scale

 :?

daron

  • Guest
Newbie to world of (Lost in Stupid Parentheses) errr..(List)
« Reply #298 on: November 20, 2003, 11:37:40 AM »
Code: [Select]
(chvars "612" "Three" (cdr (nth 2 n)) (cdr (nth 3 n)))
This example will be the same for all. First, the routine sees the name chvars, it looks for a function called chvars. When it finds it, it looks in the argument list to see if there are any required arguments:
(defun chvars (required arg's here / local variables)
(...)
)
What you are doing with the example at the top is telling chvars to set each argument to what comes after the chvars call at the top. Since there are currently four required arguments, you need to call chvars with four values. Calling each value is like doing this in each successive call:
Code: [Select]
(defun chvars ()
(setq clay (setvar 'clayer "612")
        lintype (setvar 'celtype "Three")
        lscale   (setvar 'ltscale (getvar 'ltscale))
        plwid    (setvar 'plinewid (getvar 'plinewid))
)
(setvar 'clayer clay)
(setvar ''celtype lintype)
(setvar 'ltscale lscale)
(setvar 'plinewid plwid)
)

With reusable functions, you wouldn't have to type all that each time. This portion may not be the best place for reusable functions, because you aren't changing all values in each condition, but I was hoping to give you an understanding of modular programming (reusable code). I know we discussed this in the past and I think it was over your head then. I know it can be. The first time I saw a function with arguments, I didn't understand how that was possible. Really, until you write one, it won't make sense.

amgirard2003

  • Guest
Newbie to world of (Lost in Stupid Parentheses) errr..(List)
« Reply #299 on: November 20, 2003, 01:30:56 PM »
Daron, Thanks for your reply and you're right.. It's flown over my head..

I'm keeping it simple and if it takes me to write variables over and over
then that's what i will have to do for right now.

I've fixed my code to what Kerry ahd mentioned i do with the (cond) conditional..

here's what i got so far... I know it's repetitive but it's somethin i see and understand what i'm lookin at, after i get it working i will look at improving the code and the look of it as well...


Code: [Select]
(defun c:nl (/ ans )
  (prompt "Run with Phil's routine only"); tell the user to use it with Phil's routine
  (initget 0 "T D S C E F"); Capital letters of all the Linetypes
  (setq ans
(getkword "\nSelect Line [Three/Double/Single/seCondary/(E)600/(F)208]: <> ")
  )
  (setq clay (getvar "clayer"))
  (setq cltype (getvar "celtype"))
  (setq pwidth (getvar "plinewid"))
 
  (cond ((= ans "T") ; Answer to equal Three Phase
(setvar "clayer" "612") ; Set variable "Current Layer" to 612
(setvar "celtype" "Three")) ; Set variable "Current Linetype" to Three
 
  ((= ans "D") ; Answer to equal Double Phase
(setvar "clayer" "612") ; Set variable "Curren Layer" to 612
(setvar "celtype" "Double")) ; Set varaible "Current Linetype" to Double

  ((= ans "S") ; Answer to equal Single Phase
(setvar "clayer" "612") ; Set variable "Current Layer" to 612
(setvar "celtype" "Single"))   ; Set variable "Current Linetype" to Single

  ((= ans "C") ; Answer to equal 120/240V
(setvar "clayer" "622") ; Set variable "Current Layer" to 622
(setvar "celtype" "Bylayer")   ; Set variable "Current Linetype" to Bylayer
(setvar "plinewid" 0.5))   ; Set Polyline Width to 0.5

((= ans "E") ; Answer to equal 600/347V
(setvar "clayer" "622")
(setvar "celtype" "Hidden")
(setvar "ltscale" 0.5))

((= ans "F") ; Answer to equal 120/208V
(setvar "clayer" "622")
(command "linetype" "l" "*" "conversion.lin" "")
(setvar "celtype" ))
  )

(princ)
(command "pline")
  (princ)
(setvar "clayer" clay)
(setvar "celtype" cltype)
(setvar "plinewid" pwidth)
)