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

0 Members and 1 Guest are viewing this topic.

amgirard2003

  • Guest
Newbie to world of (Lost in Stupid Parentheses) errr..(List)
« Reply #330 on: November 24, 2003, 12:56:15 PM »
Alright guys here's what i got and it seems to be working pretty good. :D

Code: [Select]
(defun c:nl (/ ans cmd clay ltype scal pwidth)
  (prompt "Run with Phil's routine only")
; tell the user to use it with Phil's routine
  (initget 0 "Three Double Single seCondary E F") ; Capital letters of all the Linetypes
  (setq ans
(getkword
  "\nSelect Line [Three/Double/Single/seCondary/E(600)/F(208)]: <> "
)
  )

  (setq cmd (getvar "cmdecho"))
  (setvar "cmdecho" 0)
  (setq clay (getvar "clayer"))
  (setvar "clayer" "0")
  (setq ltype (getvar "celtype"))
  (setvar "celtype" "bylayer")
  (setq scal (getvar "ltscale"))
  (setvar "ltscale" 1.0)
  (setq pwidth (getvar "plinewid"))
  (setvar "plinewid" 0)
 
  (cond ((= ans "Three")
(if (not (tblsearch "layer" "612"))
  (command ".layer" "m" "612" "c" "6" "" "")
  (setvar "clayer" "612")
)  
(if (not (tblsearch "ltype" "Three"))
  (command ".linetype" "l" "*" "andre (newline).lin" "")
  (setvar "celtype" "Three")    
)  
)

((= ans "Double")
(if (not (tblsearch "layer" "612"))
  (command ".layer" "m" "612" "c" "6" "" "")
  (setvar "clayer" "612")
)
(if (not (tblsearch "ltype" "Double"))
  (command ".linetype" "l" "*" "andre (newline).lin" "")
  (setvar "celtype" "Double")
)
)

((= ans "Single")
(if (not (tblsearch "layer" "612"))
  (command ".layer" "m" "612" "c" "6" "" "")
  (setvar "clayer" "612")
)
(if (not (tblsearch "ltype" "Single"))
  (command ".linetype" "l" "*" "andre (newline).lin" "")
  (setvar "celtype" "Single")  
)
)

((= ans "seCondary")
(if (not (tblsearch "layer" "622"))
  (command ".layer" "m" "622" "c" "2" "" "")
  (setvar "clayer" "622")
)
(setvar "celtype" "Bylayer")
(setvar "plinewid" 0.5)
)

((= ans "E")
         (if (not (tblsearch "layer" "622"))
  (command ".layer" "m" "622" "c" "2" "" "")
  (setvar "clayer" "622")
)
(if (not (tblsearch "ltype" "Hidden"))
  (command ".linetype" "l" "*" "andre (newline).lin" "")
  (setvar "celtype" "Hidden")
)
(setvar "ltscale" 0.5)
)

((= ans "F")
(if (not (tblsearch "layer" "622"))
  (command ".layer" "m" "622" "c" "2" "" "")
  (setvar "clayer" "622")
)
(if (not (tblsearch "ltype" "OH_SECONDARY"))
 (command ".linetype" "l" "*" "andre (newline).lin" "")
 (setvar "celtype" "OH_SECONDARY")
)
)
  )
  (command "pline")
  (while (> (getvar "cmdactive") 0)
    (command pause)
  )
  (setvar "cmdecho" cmd)
  (setvar "clayer" clay)
  (setvar "celtype" ltype)
  (setvar "ltscale" scal)
  (setvar "plinewid" pwidth)
)



The only problem i have is after i load my routine and draw my first line
it draws the line on the correct layer and the correct color but it draws the line on the "BYLAYER". When i draw a second line it draws it correctly.
Any ideas? :?

daron

  • Guest
Newbie to world of (Lost in Stupid Parentheses) errr..(List)
« Reply #331 on: November 24, 2003, 03:07:42 PM »
As far as readability goes:
Code: [Select]
(setq cmd  (getvar "cmdecho")
      clay (getvar "clayer")
      ltype (getvar "celtype")
      scal (getvar "ltscale")
      pwidth (getvar "plinewid")
)
(setvar "cmdecho" 0)
(setvar "clayer" "0")
(setvar "celtype" "bylayer")
(setvar "ltscale" 1.0)
(setvar "plinewid" 0)

That, either with the setq's in place or as I have written, would make it more readable. It won't affect how the function runs though.

I still don't think you need to set the layer if it exists or create it if it doesn't. Let's say someone turned the layer color to 3 and your standards say it should be 6. If you just did (command ".layer" "m" "612" "c" "6" "" ""), you could forgo the if statement, the tablesearch and the setvar. Plus, you'd be able to enforce the color standard you seem to be implying. So really, you're just adding more code and making it less readable.

Quote
it draws the line on the correct layer and the correct color but it draws the line on the "BYLAYER".
What are you saying here? Do you want the object color to be different than the layer color? If not, it should be bylayer, if so, you need to set the color property to what you want it to be, but unless you're changing the color of a block, you normally wouldn't do that.

amgirard2003

  • Guest
Newbie to world of (Lost in Stupid Parentheses) errr..(List)
« Reply #332 on: November 24, 2003, 03:20:17 PM »
o.k here's the problem that is happening..

I start the routine, and i choose which line i want to draw.
I select T (three) as the line i want to draw.. ( T has a value of "612" as the layer name, "Magenta" as the color of the line and "Three" as the linetype.

When i draw my first line it draws the line on "612" (correct) , "magenta" (correct) and linetype is "Bylayer" (incorrect).
I erase that line and draw a new one and it draws it with all 3 variables correctly..
Does that make any sense or did i confuse you anymore?

amgirard2003

  • Guest
Newbie to world of (Lost in Stupid Parentheses) errr..(List)
« Reply #333 on: November 24, 2003, 03:25:20 PM »
And one other thing..

You guys have all been a great help... Don't know if i would have gotten this far on my own..
I've learned quite a bit and like se7en said in another post

Quote
You learn so frickin' much when you test, play arround and inspect each expression it would be stupid not to do so.


I've learned a lot by doing what he said to do..

Thanks for all your help, really appreciate it

amgirard2003

  • Guest
Newbie to world of (Lost in Stupid Parentheses) errr..(List)
« Reply #334 on: November 24, 2003, 03:27:04 PM »
Daron,

Once again i think i answered my own question to my problem..
I'll post and let you know..

amgirard2003

  • Guest
Newbie to world of (Lost in Stupid Parentheses) errr..(List)
« Reply #335 on: December 03, 2003, 10:32:51 AM »
Howdy!!!

Well first off things with the routine are working great..
No such problems have arisen..

Sorry i haven't checked in awhile, work has been pretty crazy around here.

Well i'm thinkin about doin another routine, just haven't figured out what i wanna do just yet... but will keep you posted.

Thanks for all your help, you've all been excellent teachers.

Dre