TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: amgirard2003 on January 20, 2004, 02:53:48 PM

Title: CAD Setup Routine
Post by: amgirard2003 on January 20, 2004, 02:53:48 PM
Hey Everyone, :)

I'm looking at creating a setup routine..
I'm looking for some advice and somethings that i should keep
in mind when working on this..
Any comments would be greatly appreciated..

Thanks,
Andre

P.S-- I'm using Autolisp, I know a lot of Vlisp gets thrown around here..
Title: CAD Setup Routine
Post by: Craig on January 20, 2004, 03:02:43 PM
Setup routine for a new drawing? If thats the case I would incorporate:
Commonly used layers, linetypes, styles (fonts, dims, etc..)
Is that what you were asking? :?
Title: CAD Setup Routine
Post by: Keith™ on January 20, 2004, 03:02:55 PM
Ok, lets think about what you want in a setup routine, nevermind what language it will be written in, you should decide that based on what you need and want to do.

Come up with what we liek to call pseudo-code

..
do this
do that
do the other thing
and don't forget to do this too
..

Once you kow what you want to accomplish, write bits of code to do each one individually, then put them together to form one command.

Answer these questions too...
Do you need/want it to run automatically ... on the first drawing opened? on all drawings opened?
Do you want to run it manually?
Should the user be notified or should it be transparent?

I am sure there are many other questions you need to answer but these will get you started in the right direction.

once you get a little clearer idea come back and lets discuss it a bit.
Title: CAD Setup Routine
Post by: amgirard2003 on January 21, 2004, 10:04:02 AM
O.k i'll give you all the run down...
But first i should let you all know that i'm still a newbie when it comes to writting Lisp... I've written one routine so far....
I think working on a routine like this will give me a broader view on coding and overall concepts of Lisp programming.
I want to take one thing at a time and i know this will be quite painful as well, All i ask, if anyone is willing to help me out is for some patience..
I'm open and willing to learn... :)

Here's the run down as to what i want to happen..

When Autocad is launched it sets up as it always does..
The routine i want will be command driven.. such as (CADSTART or CADSETUP).

Once the command is entered i would like the following to happen..

-A menu pulldown will be loaded.
I want a menu pulldown to load only when the command is invoked.. Once invoked the menu will load commands that i would like to create in the future.

-A list of layers will be created with it's following characteristics.
Speaks for itself.

-Special Fonts will be loaded with Slides to pick from.
A command that i will place in the menu that will launch a slide of all the available custom fonts. Once the user selects the slide, the text command begins.

-A slide of details will be loaded..
same as above but will only work in PS mode... If launched within model space mode a message will be displayed telling the user that it will not work in model space and then will flip to paper space.

-The user will be prompt to enter a scale for which they want it to print in PS mode.
When the user enters a scale of 1"=20'-0", i want to have all text, linetypes and details to reflect that scale in PS mode

-A list of layout pages will be loaded.
Command will be put into the menu pulldown and when selected a slide will be displayed showing all available layouts ( Construction , Subdivision, Conversion) and so on..

Any input would be great...

Thanks,
Andre


 :D
Title: CAD Setup Routine
Post by: deegeecees on January 21, 2004, 10:30:33 AM
Whoa, slow down there cowboy!

Thats quite a list of things to do. I will say that its alot to teach someone who has just started out in the world of Lisp and such. But, I will also say that, although (we) won't write all that code for you, (we) will point you in the right direction if asked nicely. I guess I can start you out on this first task...

(WE) need to look at is how this is all going to be loaded and when into memory. Now, as in most cases there are 2 or 3 right ways, and a million other ways. I would take a look at what version of AutoCAD you are using first.

After (we) attain this bit of info, we can proceed accordingly. :D
Title: CAD Setup Routine
Post by: amgirard2003 on January 21, 2004, 10:40:16 AM
I know it's a lot but i think i can handle it..
I think one piece of the puzzle at a time and things will go pretty well..
I know and understand that there will be bumps in the road but i won't be giving up on learning this..

I have 2 books...
Autolisp in Plain English by George O. Head... old version of the book
AutoCadet's guide to Visual Lisp by Bill Kramer (This book is confusing)


I'm using AutocadMap 5 so that would be AutoCad 2001
Title: CAD Setup Routine
Post by: deegeecees on January 21, 2004, 10:47:29 AM
Ahhh... Good ol' Gearge O. Head. He was my first book on AutoLisp too.

OK, we're off to a good start...

Now, take a look at your HELP pull-down. There should be a "Developers Help" section. This will be your savior when it comes to finding out how to do things. If you do a little research you will find that the ACAD2000DOC.LSP is loaded into memory when you first start AutoCAD. This will be the preferred method of doing things in this application. Find your acad2000doc.lsp on your computer and open it up. Do not modify this file at this point.

I need to know if you are going to be sharing these routines with other users.

We will continue after this information is attained.
Title: CAD Setup Routine
Post by: amgirard2003 on January 21, 2004, 10:58:02 AM
O.k i've found the file...
I'm currently not gonna share the file with anyone else but in the future i will be..

George O. Head book is a good book and it's somethin i always refer too for refreshing my mind with some of the basics until it finally engraves itself into my mind.
The other book is too complex... goes into too much details and assumes you've had experience with LISP..

So it was refreshing to find this site...
Title: CAD Setup Routine
Post by: deegeecees on January 21, 2004, 11:06:31 AM
OK, with the acad2000doc.lsp file open, do a "saveas" and create a new directory on your C:\ drive. Lets call it "acad_start" for the sake of continutiy. save this acad2000doc.lsp in this directory.

With AutoCAD open, right click on your command line and click on "Options". Go to the support directory section and "Add" the new directory to your list.

Next, move the newly added "acad_start" directory to the top.

What this will achieve is that AutoCAD will find the acad2000doc.lsp file that we are about to modify in the first directory in the support list and stop looking for it. This way all modifications will stay local to your machine and you can always go back to your "Vanilla" AutoCAD state if you need to.

After you accomplish this, we'll move on.
Title: CAD Setup Routine
Post by: amgirard2003 on January 21, 2004, 11:19:06 AM
O.k...I've created a new folder and the Acad2000doc.lsp is saved in that folder. I've gone into the options and added a new search path under support and moved it to the top...

I await further instructions
Title: CAD Setup Routine
Post by: deegeecees on January 21, 2004, 11:37:00 AM
Ok, what I've set up for you here is a prerequisite to loading either VLisp, or VBA programs that will function as described in you post above. Your functions you described (if I am correct here) will activate when a command is called. This routine (command) will be loaded everytime you start a new drawing or open one up. To do this you need to set the "acadlspasdoc" variable to 1. We will do this in the acad2000doc.lsp file to ensure this.

In the acad2000doc.lsp file, append this to the END of the file:

;;;;;;;;;;;;;;;;Startup Functions;;;;;;;;;;;;;;;
(setvar "acadlspasdoc" 1)
Title: CAD Setup Routine
Post by: deegeecees on January 21, 2004, 11:42:36 AM
Now, we need to create the functions. Lets tackle the outline of the achieved result here. I need to know EXACTLY what you are trying to do. Not just a generalization, give me every aspect of it.

If you could give me a detailed explanation (a bit more than previously posted) I can point you in a more detailed rather than general direction.

After this is achieved we will proceed, take your time.


(for anyone else out there reading this post, your input would be appreciated at this point) :D
Title: CAD Setup Routine
Post by: amgirard2003 on January 21, 2004, 11:52:09 AM
Quick question for ya..

I looked up "Acadlspasdoc" in the help section to read what it's purpose was..

Help says:
"Specifies whether acad.lsp is loaded at startup or with each drawing."

If set to true:-is loaded with each drawing
If set to False:- is loaded with the first drawing at startup

Default setting is set to True

My question is If the default is set to 1 which i assume is true then
why enter this to the end of the file?
Title: CAD Setup Routine
Post by: deegeecees on January 21, 2004, 11:56:51 AM
It's been my experience that other users will mess around with settings. This is just a safe guard to protect against this. This is why I asked the multi-user question. Whe you do finally get this thing on its feet and have multi-user functionality, you will thank me. :D
Title: CAD Setup Routine
Post by: amgirard2003 on January 21, 2004, 12:08:21 PM
What i'm trying to do is speed up and standardize the drawings i work with.
Where i work we have 4 drafters and 4 people that do things differently..
Standards are not met within all 4 of us here.. It's very frustrating to work like this and me being the only one of the 4 willing to learn Lisp know there's a way to standardize the basics..

The basics involve :- Layers, Fonts, Linetypes, Layouts, details, scaling etc.

Layers:- When the command is launched all the layers that we use will be automatically loaded with their corresponding characteristics.

Fonts:- Most used fonts will be loaded and set as far as Height and so on and will be available to be selected through a slide for easy selection.

Linetypes:- Custom linetypes will be loaded as well

Details:- same use as the fonts

any questions??? feel free to ask.. i'll try an elaborate some more
Title: CAD Setup Routine
Post by: deegeecees on January 21, 2004, 12:34:26 PM
I have had the same problem with muti-users. Being that the CAD manager (ususally) knows little, or nothing by way of Lisp or VBA, I take it upon myself to head up the standards enforcement.

With the introduction of AutoCAD2002, there came an attempt to resolve these issues by means of a "wish-list" and does so in a general way. To refine this as well as for those without AutoCAD2002, you neeed a more exclusive approach.

I can give you some examples that may sway you from your immediate ideas to a more applicable direction. What I did for one company is this:

As far as everything was concerned, all routines would not work unless the companies (or other set-up) title block was in place and scaled properly. This would insure that al batch routines would function properly and give me less of a programming headache.

All layers linetypes and text styles were set up according to a Drawing Code. This may not be a part of you companies document tracking, but may give you something to push for. This worked in a manner of an attributed title block.

Synopsis:
Drawing is opened
acad2000doc.lsp loads title block program
drawing code is input
title block is setup properly
basic routines are run
drawing code is evaluated
layers are set
linetypes are set
drawing scale is set (can be used for details)
text styles are set

This may give you an idea of how to attack this standardization problem
Title: CAD Setup Routine
Post by: amgirard2003 on January 21, 2004, 12:46:13 PM
You wouldn't believe the crap that comes through this place..
And the consultants call themselves AutoCad experts and it's amazing some of them don't even know how to use PS/MS...
One time i got a drawing and it was labelled at 1"=3/8" and i couldn't believe my eyes... they drew the whole drawing in MS at 3/8" of an inch...
can u believe that...

Eveything you just wrote in your previous message is exactly what i want to achieve... We have a drawing code but no one around here seems to follow it...
If i can achieve this routine it will force them to use the standards...
Title: CAD Setup Routine
Post by: deegeecees on January 21, 2004, 01:03:56 PM
There are ways to "lock-out" users from doing ANYTHING in AutoCAD but this is an extreme. There will always be the user who just will not follow directions and do it their own way. I used to set a lock out based on their login name that would set an AutoCAD profile with nothing in it when these people were found guilty. Just an exercise for me, but a rude awakening for them. This will "thin the pack" as it is said.

I realize that I had started you off prematurely. We needed to establish these things before I pointed you in the direction you are going (although it was the correct one).

Another question is:
What type of management structure is in place at your employment, and can you develop these standard enforcing routines with their blessing?
Title: CAD Setup Routine
Post by: amgirard2003 on January 21, 2004, 01:31:26 PM
As far as management... it's pretty relaxed here... any ideas are accepted pretty well here so it won't be too bad
Title: CAD Setup Routine
Post by: deegeecees on January 21, 2004, 01:50:03 PM
Ok, I'll give you something to work on:

Append the code below to the acad2000doc.lsp file that we saved previously. Save the acad2000doc.lsp file, and open a drawing with a relevant title block in it (Replace the "YOURBLOCK" with the name of your titleblock).

(setq is_tb (ssget "x" '((2 . "YOURBLOCK"))))
(if is_tb
    (progn
        (setq qty_tb (sslength is_tb))
        (if (= 1 qty_tb)
            (alert "Yeah, I rock!")
            (alert "Multiple Instances!")
        )
     )
    (alert "Block Not Found!")
)


This will get you started. These are just basic boolean if's, that check for your title block. If more than 1 instance of the titleblock is found, you are prompted. If no title block is found, you are prompted as well.

I should be back tomorrow. :D
Title: CAD Setup Routine
Post by: amgirard2003 on January 21, 2004, 02:24:27 PM
No problem...I'll be here tomorrow as well as i have questions for you..
It looks like it's just me & you on this project.

Since i'm still new i still get confused as to what i read when it comes
to code...
Could you explain with comments next to the code to say what it is doing?

I appreciate all your help

Thanks,
Title: CAD Setup Routine
Post by: amgirard2003 on January 23, 2004, 09:26:41 AM
Well i guess i'm on this on my own...
I'll post any questions or problems that i might have..
I think i have a good vision as to what i want to do...
I'll keep you posted.
Title: CAD Setup Routine
Post by: Mark on January 23, 2004, 09:31:06 AM
>Well i guess i'm on this on my own...
No, we are still here, watching and waiting. :D
Title: CAD Setup Routine
Post by: deegeecees on January 23, 2004, 09:55:38 AM
Yup 8)
Title: CAD Setup Routine
Post by: Keith™ on January 23, 2004, 10:59:40 AM
Watching like a bunch of hyenas looking for the kill :twisted:
Title: CAD Setup Routine
Post by: deegeecees on January 23, 2004, 12:41:45 PM
For when you finally have exhausted every other possibility, you come running into the arms of the good people here at "The Swamp", and YES, it feels like a warm blanket on a cold December morning. Come hither my weary traveler, and suckle up to the knowledge of the nipple from which we adorn thee heretofore and thus, and thus, and thus...

Please slap me! :roll:
Title: CAD Setup Routine
Post by: Keith™ on January 23, 2004, 01:06:24 PM
SLAP
Title: CAD Setup Routine
Post by: deegeecees on January 23, 2004, 02:02:03 PM
Whew...!

Thanks.


 :wink:
Title: CAD Setup Routine
Post by: Keith™ on January 23, 2004, 02:26:39 PM
:)
Title: CAD Setup Routine
Post by: amgirard2003 on January 23, 2004, 02:39:45 PM
Alright boys... I will run back to "THE SWAMP" but i'm not suckeling on anything...  :)
It might be a few days before i post anything but i will be back..
I've downloaded a DCL manual off of afralisp.com, so that will be my reading material this weekend..
Be in touch with "The Swamp" soon..
Title: CAD Setup Routine
Post by: amgirard2003 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
Title: CAD Setup Routine
Post by: amgirard2003 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
Title: CAD Setup Routine
Post by: daron 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.
Title: CAD Setup Routine
Post by: deegeecees 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: ).
Title: CAD Setup Routine
Post by: amgirard2003 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,
Title: CAD Setup Routine
Post by: deegeecees 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
Title: CAD Setup Routine
Post by: SMadsen 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.
Title: CAD Setup Routine
Post by: deegeecees 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
Title: CAD Setup Routine
Post by: daron 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.
Title: CAD Setup Routine
Post by: amgirard2003 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 :? :?
Title: CAD Setup Routine
Post by: amgirard2003 on January 26, 2004, 12:45:22 PM
well i'll try and figure this out..
Title: CAD Setup Routine
Post by: deegeecees 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?
Title: CAD Setup Routine
Post by: daron on January 26, 2004, 12:56:24 PM
I thought I did that with my code. What's with copying that?
Title: CAD Setup Routine
Post by: amgirard2003 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...
Title: CAD Setup Routine
Post by: amgirard2003 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
Title: CAD Setup Routine
Post by: deegeecees on January 26, 2004, 01:37:13 PM
I'll save you the trouble of "LOOKING IT UP". <----hint

An "IF" statement checks for a condition, in this case, Daron combined additional conditions all in the same line to, basically, save space/time, and it's a bit more professional (if there is such a thing).

The "IF" statement now has to do 2 things, if the statement is true, do THIS, if the statement is not true, do THAT.

Are you with me?
Title: CAD Setup Routine
Post by: daron on January 26, 2004, 01:52:34 PM
To the above, IF I (drogers) am invoking the command, do the first statement. If somebody other than drogers is invoking the command, do the other. If you test the test, you'll see that (= (strcase (getvar 'loginname) t) "drogers") in your case will equal nil. If you change "drogers" to whatever your username is, it will return t. If true the first statement will be run. If nil, the second statement will be run. Cond is a little different in that whatever condition is true, all the code inside that block will be run.

Quote from: Andre
I know you'll all be asking why start with a big project like this..

My first undertaking is two pages long. It'd be more if it didn't have reusable code in it. So, I'm not asking why you're starting with a big project like this. What you need to do is create small functions to do each job then call each function in your startup code. You'll understand as you go. Don't eat the whole elephant. Chew on one set of standards at a time, like layers, then whatever else. Create a new function for each piece. We'll show you how to put it together later.
Title: CAD Setup Routine
Post by: daron on January 26, 2004, 01:54:05 PM
to find out what your loginname is, if you're unsure, test this (getvar 'loginname).
Title: CAD Setup Routine
Post by: amgirard2003 on January 26, 2004, 02:12:19 PM
Yupe i'm with ya on the IF statement

I can understand about making small functions for each part and then put it all together in the end..

I have made one quick function for the layers

Code: [Select]


(defun newlayers (/ cmd clay)
 (setq cmd (getvar "cmdecho")
 (setq clay (getvar "clayer" "0")
 (setvar "cmdecho" 0)
(command ".layer" "m" "1" "c" "1" "" ""
                ".layer" "m" "2" "c" "2" "" ""
                ".layer" "m" "3" "c" "3" "" ""
)
(setvar "clayer" "1")
(setvar "clayer" clay)
(setvar "cmdecho" cmd)
(princ)


i haven't come up with a full list for the layers... but this gets my point out..
what are your thoughts?
Title: CAD Setup Routine
Post by: daron on January 26, 2004, 02:32:18 PM
Here's (http://www.theswamp.org/phpBB2/viewtopic.php?t=35&postdays=0&postorder=asc&&start=0)  a good place to start. A lot of reading, but about midway through the second page, you'll find Smadsen getting really involved. I'd scan/read through the entire 5 pages. It may be very close to what you're looking to do. Do a search for other threads using layer as a keyword in vlisp hackers and see what else you come up with.
Title: CAD Setup Routine
Post by: amgirard2003 on January 26, 2004, 02:40:19 PM
Thanks Daron,

I'll Print it out and add it to my homework pile..
Title: CAD Setup Routine
Post by: deegeecees on January 26, 2004, 02:46:59 PM
Very nicely commented. Stig is more than just... well... Stig. Where was this forum when I was starting out, sheesh. I'd spend days poking around and testing this and that, and now people can get full functions, commented even.
Title: CAD Setup Routine
Post by: SMadsen on January 27, 2004, 04:31:43 AM
Quote from: deegeecees
Where was this forum when I was starting out, sheesh.

I don't think Mark would have enough bandwidth for that   :lol:  :lol:  :lol:


Andre, you're doing a good job trying to figure it out but somehow I don't think you have the patience to do an even better job. Whether or not that assumption is right, it's not uncommon to lack patience - especially when trying to squeeze a little coding in between daily choirs.

But - and I think most here can testify to this - if you don't try to figure out exactly what it is you are asking the machine to do then you'll spend twice, triple or quadruple the amount of time writing, editing and debugging code.

The rather simple code that Daron posted is an excellent example of how more understanding could be gained by testing .. and testing and testing.

When you look up the IF function in the help reference ('cos you did that, right?), it will tell you that the first expression is a test expression, that the second expression will be evaluated if the test expression is not nil and that the third expression will be evaluated if the test expression is nil.
That's ALL you need to know about IF. Understanding that very basic concept allows you to decipher any IF statement - at first by testing and later by merely looking at it.

So, how to test Daron's IF statement? You made the first step, which is to  identify each of the components that the IF statement is made up of:

Code: [Select]

function name  :  (if
test expression:    (= (strcase (getvar "loginname") t) "drogers")
2nd expression :    (command ".zoom" "")    ; line 1
3rd expression :    (command ".zoom" ".9X") ; line 2
end of function:  )


Now use the command line in AutoCAD and test each component. The expression that makes the decision is the test expression, which is always the first expression (as pointed out in the help file). Break it down, identify each component and test it, always starting with the innermost expressions:

Command: (getvar "loginname")
"andre"

Command: (strcase (getvar "loginname") t)
"andre"

Hmmm, you might say, this gives the same answer so why use STRCASE? Let's test that function. Looking it up in the help reference will tell you that it converts a string to either uppercase or lowercase. The third argument, if present, specifies which operation to perform. Test it to understand it:

Command: (strcase (getvar "loginname"))
"ANDRE"

Command: (strcase "AnDrE")
"ANDRE"

Command: (strcase "AnDrE" t)
"andre"

Ahh, so Daron may have experienced that login names comes in all forms and shapes and wants to make sure that he is only comparing lowercase strings. That's why he added the second argument, T.

Now that you have deciphered all arguments to the equality function, test it:

Command: (= "andre" "drogers")
nil

Command: (= "drogers" "drogers")
T

Command: (= "DRogers" "drogers")
nil

Now you know what IF has to work with in order to decide which expression to choose, the second or the third. If the test is not nil then it chooses to evaluate the second expression. If the test is nil then the third. The outcome of the test expression is the "pointer" to the selected statement.

To sum it up, if you are not quite sure why a statement does as it does then TEST it. Break it down into components and test each of the components. Think of the command line as being your own personal code testing tool!
Have the help file ready in the background, already opened at the "AutoLISP reference" so you can quickly identify the arguments to a function. Note which data types that the function accepts and compare them to your test results.
Title: CAD Setup Routine
Post by: amgirard2003 on January 27, 2004, 08:17:02 AM
Smadsen:-

Thanks for clearing a big fog that was in front of my eyes...
You're the first person that has posted a message like this for me, to help me figure out what i'm doing..
Like you said i some times run out of patience in trying to figure what i'm doing but like the sayings goes

Quote

If I'm reading Chinese and I don't know Chinese... I'm not gonna get too far.


And that's when i get frustrated...
And i know it frustrates other people trying to teach me how to write code and so on...
I look for any kinds of tips that will help me think my way through a project, conceptually and coding wise as i've never had any programming experience ever.....


I know in my head that it will take a lot of time and a lot of practice before i will get a hold on what i'm doing and then be able to do things on my own and i'm willing and wanting to get to that point...
Title: CAD Setup Routine
Post by: daron on January 27, 2004, 09:31:56 AM
Good! Stig, that was an awesome example. Thanks for the complement. You hit the nail right on the head about the strcase username thing.

Andre', you've used cond statement in previous code, yet lacked understanding of IF. Now that you have a new found knowledge of IF and a little understanding of cond, I have a challenge for you. Study, test and describe, the elements of each function; what makes them similar, what makes them different, and what in both cases, will make or allow them to perform actions on multiple items for one true statement. Example
Code: [Select]

(cond (t
          (do this)
          (do this)
          (do this)
         )
         (t
          (do this)
          (do this)
          (do this)
         )
)
(if (t)
    (what goes here
     (do this)
     (do this)
    )
    (and here, to make this work?
     (do this)
     (do this)
    )
)

I don't want a quick answer. I want you to have a better understanding of both. Remember, test, test, test. Find code on this forum. Pick it apart, test it and understand.
Title: CAD Setup Routine
Post by: CAB on January 27, 2004, 09:33:09 AM
am2003,

Your first project is a bit ambitious in my opinion
but it looks like you are making progress.

The folks helping you are VERY knowledgable and sometimes
they assume you understand the first time you are told.
I myself have to redo several times before I fully understand
and then there are some aspects that I don't learn until later.

What I am trying to say is hang in there and they will get you there.

Stepping through each bit of code in the VLIDE and watching the flow
and the LAST VALUE will tell you volumes.
You know how to watch the LAST VALUE, right?
Just making sure, as it's very important.

Hang in there.

CAB
Title: CAD Setup Routine
Post by: amgirard2003 on January 27, 2004, 10:03:40 AM
Quote from: CAB
am2003,

Stepping through each bit of code in the VLIDE and watching the flow
and the LAST VALUE will tell you volumes.
You know how to watch the LAST VALUE, right?
Just making sure, as it's very important.

CAB


Can you elaborate more on this point.. don't quite know what you mean?
Title: CAD Setup Routine
Post by: daron on January 27, 2004, 10:12:07 AM
Here (http://www.theswamp.org/super.fusion/Tutorials/Vlide%20Editor%20Tutorial/VLispTutorial.html) is a tutorial I wrote on the vlide. It isn't complete, but it should help you learn how to use the inspect button to test code. I personally like testing with the inspect button rather than testing on the command line. It gives a little more detail about the results of a test. I think Stig's site also has a tutorial on the vlide. I'm not sure though.

As far as CAB's post, "watch" is really the key word there. There is a watch window that reads the value of each variable you tell it to watch.
Title: CAD Setup Routine
Post by: SMadsen on January 27, 2004, 10:49:52 AM
Quote from: Daron
I think Stig's site also has a tutorial on the vlide.

Nope, sorry (but sign up for the course and you'll get a mini tutorial .. umm, when translation is done :) )
I might put it there later this year, though.
Title: CAD Setup Routine
Post by: daron on January 27, 2004, 11:08:30 AM
Must've been on Afralisp (http://www.afralisp.com) then.
Title: CAD Setup Routine
Post by: amgirard2003 on January 27, 2004, 11:22:36 AM
Quote from: Daron
I have a challenge for you. Study, test and describe, the elements of each function; what makes them similar, what makes them different, and what in both cases, will make or allow them to perform actions on multiple items for one true statement. Example
Code: [Select]

(cond (t
          (do this)
          (do this)
          (do this)
         )
         (t
          (do this)
          (do this)
          (do this)
         )
)
(if (t)
    (what goes here
     (do this)
     (do this)
    )
    (and here, to make this work?
     (do this)
     (do this)
    )
)



Here's my explanations and correct me if i'm worng which i'm sure you will do..
First the Cond Function

The Cond function evaluates all the arguements in the list supplied to it in order until it finds one that is not equal to nil. Once it finds an arguement that is TRUE it locks itself to that arguement and does the following instructions that are attached to that arguement.
So in the following.. Cond is looking for either t = Name or t = Sport..
If the arguement doesn't equal either the cond will exit itself.

(cond (t = Name
          (ask the user his name)
          (ask the user his age)
          (ask the user his weight)
         )
         (t = Sport
          (ask the user his favorite sport)
          (ask the user his favorite team)
          (ask the user his favorite player)
         )
)

The IF function work a lot like the Cond but there is a difference.
The Cond function runs through all the arguements until it finds a match.. while the IF is more like "either it's there or it's not" IF it's there do this and this and that, IF it's not then do this and that and that...

So in the following i'll use Sport and Name again in this example the If is looking to see if t = name.. If it does it does the following instructions that are attached, IF t doesn not equal t then jump to the next set of instructions.


(if (t)
    (= name)
          (ask the user his name)
          (ask the user his age)
          (ask the user his weight)
  )
    (ask the user his favorite sport)
          (ask the user his favorite team)
          (ask the user his favorite player)
    )
)

How far off am i on this?  i got a little confused on the IF... but i think it's right..




[/code]
Title: CAD Setup Routine
Post by: CAB on January 27, 2004, 11:27:45 AM
andre'

Here is a quickie.

Open VLIDE, I assume you have used it.
If not stop here & ask.

Click the NEW FILE icon.
Paste the code below in it.

Click the TOOLS pulldown
Click "Load Text in Editor"
 
Your routine is loaded in ACAD

Click the Watch window icon, One with screen in background & eyeglasses in for ground.
Move your cursor to each icon and pause until you see the label pop up to tell what each is.

At this point a "Watch Window" is on the screen.
You should see "*LAST VALUE* =" in the window.
If not click the eyeglass icon and pull down the Add Watch selections and select *LAST VALUE*

Now high lite var2 and click the eyeglass icon, var2 should be in the watch window.
Do the same for var1.

Put your cursor just before (setq var1 or high lite the parentheses & click the open hand icon.
This is Toggle Breakpoint icon. Which will pause the routine when processes get to that point.

Switch to acad and enter test

You will be returned to VLIDE at the break point.

Now is where the fun begins.....

Click the parentheses with arrow to center icon, this is the "Step Into" icon.
This will single step you through the routine.
After each click look at the LAST VALUE to see what is returned.
Some times nil is returned when there is no logical result from the action within the parentheses
like (prompt "text")

Step through the entire routine.

To the programers, I am still a beginner so if I misspoke please correct me.

Enjoy

CAB

Code: [Select]
(defun c:test()
  (setq var1 "Andre")
  (setq var2 "Alan")

  (if (= var1 "Andre")
      (prompt (strcat "\nI found " var1))
      (prompt (strcat "\nI did not find " var1))
  )

  (setq var1 "Daron")
  (if (/= var1 "Andre")
      (prompt "\nI did not find Andre")
      (prompt "\nI found Andre")
  )

 
  (if (= var1 "Andre")
      (prompt  "\nI found Andre")
      (prompt (strcat "\nI did not find Andre, \nbut found " var1))
  )

  (if (and (/= var1 "Andre") (= var2 "Alan"))
    (progn ; this is needed when you have more than one group of code
      (setq var1 "Andre")
      (prompt  "\nI have restored Andre")
    ); end progn
    (prompt  "\nI found Andre and Alan")
  )


  (if (and (/= var1 "Andre") (= var2 "Alan"))
    (progn ; this is needed when you have more than one group of code
      (setq var1 "Andre")
      (prompt  "\nI have restored Andre")
    ); end progn
    (prompt  "\nI found Andre and Alan")
  )

  (princ)
); end defun
Title: CAD Setup Routine
Post by: daron on January 27, 2004, 12:30:25 PM
Quote
(if (t)
(= name)
(ask the user his name)
(ask the user his age)
(ask the user his weight)
)
(ask the user his favorite sport)
(ask the user his favorite team)
(ask the user his favorite player)
)
)

How far off am i on this? i got a little confused on the IF... but i think it's right..


First of all, in this (t) is just there as a constant to always evaluate to true. (= name "Andre")  should be used in place of (t). If you look at CAB's post, you'll see a little subr in there called progn. Take note of that and read this (http://www.theswamp.org/phpBB2/viewtopic.php?t=341). Note especially the last quote I put in it. That should help. The links I put in there have got to be the most mind blowing stuff about lisp and its author. Tons of reading there. It's my personal opinion that knowing how to program isn't enough. Know background of the language syntax and reasons it came about help form your understanding of the language and its intended uses.
Title: CAD Setup Routine
Post by: amgirard2003 on January 27, 2004, 01:05:05 PM
Thanks Daron,

I bookmarked the site and will read it along with all the other sites i have marked as well..
Title: CAD Setup Routine
Post by: daron on January 27, 2004, 01:26:27 PM
Take it one step at a time. Don't get overwhelmed. Did you see what makes the if statement perform multiple tasks and that it is in cond, just not as obvious?
Title: CAD Setup Routine
Post by: amgirard2003 on January 27, 2004, 01:44:16 PM
Got me a little confused there...

But if i can see what you're asking me to look for :

IF: works in pairs , meaning (do this if true) (If not then do this)
Cond: works with how many arguements you want to pass to it..

That's the clearest difference i can see in my own eyes..
Title: CAD Setup Routine
Post by: amgirard2003 on January 27, 2004, 01:55:30 PM
I understand a lot of things conceptually but it's when i have to write it out in code (syntax) that i have the biggest problem... There are times i don't know where to begin, what i'm supposed to put in the code and how to put it together.. There are times where i've tried experimenting and put some code together and to me it looked correct but AC didn't like it... I spent an hour after tryin to figure what could be wrong but never find what was wrong..

That's the part that frustrated me the most... I have the whole plan in my head but can't seem to put it into code.
Title: CAD Setup Routine
Post by: CAB on January 27, 2004, 03:08:15 PM
andre'

I was at you level not too long ago.
Every bit of code was made with the manual in hand
and I spent hours chasing things that are obvious to me now.

Learning to work VLIDE & the WATCH window are critical to
your rapid improvement to the next level.

Don't hold back, post your code here and you will receive the
help you need, not criticisms.

They hold that back for later, just kidding. :)

My path was to take routines I have found, they are everywhere.
I wanted it to do something my way, so i had to find out how it
worked and then adjust it to do what I wanted.

Then I found more complicated routines and commented every line of
code I understood or thought I did. Then post it and the helpful
people here will correct your misunderstandings of the code and
fill in the blanks. Usually leading to instruction on the parts
that are not understood and a "How To" do it differently.

There are several recent threads that are of helping new coders.
Perhaps someone can link you to them. Good reading.

CAB
Title: CAD Setup Routine
Post by: daron on January 27, 2004, 03:20:46 PM
It comes with time. What I'm trying to get at is this:
If, natively has three parts. A test of true or nil (false) and one or two things to do in either case. We've covered that.
Cond, as you've stated performs multiple tasks based on a test that results in true. If there are multiple test statements in cond and all result in a true value, only one will be processed. Regardless of that, in the if statement there are only two options, BUT they can be nested, i.e.
Code: [Select]

(if (= a b)
    (if (= a c)
        (if (= a d)
             (progn
                (if true in all three cases do this)
                (you could also put this in as something to do for true if you wrap it in a progn, as you see)
              );end progn
              (do this if a is not equal to d, but is equal to c and b)
         );end if
       (do this if a was not equal to c, but is equal to b)
     );end if
);end if

Note: there is something to do in case of nil in both nested if's. There is also a progn. The progn will make if work similar to cond in that it will perform more functions. That is what I want you to see. The quote from the John McCarthy link I sent you to earlier, that I quoted in my post, mentioned cond's progn statement. This is telling me that cond is similar to if in that it too needed a progn function to act like it does, but John McCarthy embedded that within the cond statement. Last thing: in the above example what would be the return value of IF, if a is not equal to b?

I don't want to confuse or frustrate you. I'm sorry if I do. As far as understanding things conceptually... I, and most likely everybody else, has the same problem. It is only through testing code that you will begin to really understand what works and what doesn't work in programming. From your writing, you seem to be native to a language other than English. When you started learning English or any other language for that matter, was it possible to read and understand concepts of the language and then jump out and speak fluently? No! I highly doubt it. You had to test the language and make many mistakes, before getting to the level with which you could speak or write fluently. Programming is the same way. You can do all the reading you want, but until you try it out, test it out and realize the return values of each function, nobody will ever learn it.

What CAB just said about finding code and testing it, look under the Show Your Stuff forum, here. Copy the code, even if you don't understand it. Test it, and ask questions in this forum about it. CAB has recently, since this board has been up, really started to branch out with greater understanding of lisp. I learned some new stuff back in April that pushed me beyond where I was before that.
Title: CAD Setup Routine
Post by: Keith™ on January 27, 2004, 09:49:00 PM
I have been lurking in the background keeping an eye on things and these guys would not steer you wrong. If something does not work like you expect, then ask and post code. If you don't understand allof the code, no worrys, you will learn in time. Pick a few basic commands to actually learn, add more as you become familiar, and by all means pick apart others code. I have went back and looked at code I wrote 4 or 5 years ago and asked myself why did I do something so silly when this command would work better...it is all a learning experience and soon enough you will be coding with the best of them, particularly if you apply yourself.
Title: CAD Setup Routine
Post by: amgirard2003 on January 28, 2004, 08:06:09 AM
Quote from: Daron
BUT they can be nested, i.e.
Code: [Select]

(if (= a b)
    (if (= a c)
        (if (= a d)
             (progn
                (if true in all three cases do this)
                (you could also put this in as something to do for true if you wrap it in a progn, as you see)
              );end progn
              (do this if a is not equal to d, but is equal to c and b)
         );end if
       (do this if a was not equal to c, but is equal to b)
     );end if
);end if

in the above example what would be the return value of IF, if a is not equal to b?



In the above example IF the return value would be NIL (false)

I appreciate all the responses, I know with time that i will get a hang of all this... I'm pretty dedicated, I've got 3 books and many things i've downloaded off some websites and have been reading them non stop...not too sure if i'm understanding but i'll be re-reading the chapters to try and comprehend better.


Getting back to my project, let's say we work on little bits and pieces at a time.

How about we start with the layers part?
When the routine executes the following layers would be created

Here's the code i came up with, i would like your input.

Code: [Select]

;**************************************************************
;***********************Setting of Layers**********************
; Pseudo Code
; When the OK button is pressed on the Setup dialog box the following
; layers will be created.

(defun newlayers ( / cmd clay) ; defined the function as newlayers with local variables CMD CLAY
  (setq cmd (getvar "cmdecho")) ; set variable cmdecho to cmd for temporary status
  (setq clay (getvar "clayer" "0")) ; set variable clayer to clay for temporary status
  (setvar "cmdecho" 0) ; set variable cmdecho to 0, to disable commands being echoed to the command line
 
  (command ".layer" "m" "1"    "c"    "1"    ""    "" ; Start Layer command and create the following layers
  ".layer" "m" "2"    "c"    "2"    ""    "" ; ".layers" is the layer command, "m" stands for make
  ".layer" "m" "3"    "c"    "3"    ""    "" ; "1" is the name, "c" is the color, "1" is the color
  ".layer" "m" "4"    "c"    "4"    ""    ""
 ) ; End of the Layer command
  (setvar "clayer" "1") ; set current layer to 1
  (setvar "cmdecho" cmd) ; set cmdecho back to original state with variable cmd
  (setvar "clayer" clay) ; set clayer back to original state with variable clay
  (princ) ; silent exit
) ; end of defun function


These are a few layers, not all the layers i will be using but gives the idea behind what i want to do.
Title: CAD Setup Routine
Post by: Mark on January 28, 2004, 08:25:40 AM
you could also make your function more resuable by adding arguments
to the function.
Code: [Select]

; defined the function as newlayers with local variables CMD CLAY
; lay_name = layer name to create, must be a string
; color = color of created layer, must be an integer
(defun newlayers (lay_name color / cmd clay)
  (setq cmd (getvar "cmdecho"))
  (setq clay (getvar "clayer" "0"))
  (setvar "cmdecho" 0)
 
  (if (= (type lay_name) 'STR); if var is a string
    (if (= (type color) 'INT); if var is a integer then create the layer
      (command "._layer" "m" lay_name "c" color "" "")
      )
    )
 
  (setvar "clayer" lay_name)
  (setvar "cmdecho" cmd)
  (setvar "clayer" clay)
  (princ) ; silent exit
) ; end of defun function

you would use the function like so (newlayers "1" 100) to create
a layer named '1' with a color of '100'
Title: CAD Setup Routine
Post by: Keith™ on January 28, 2004, 08:40:56 AM
I posted a pure lisp version (http://theswamp.org/phpBB2/viewtopic.php?t=690) to create layers in "Show Your Stuff" last night. It allows you to create a layer that is off/on thawed/frozen locked/unlocked and any color using the ACI. If the layer already exists it will update the status to the values passed.
Title: CAD Setup Routine
Post by: amgirard2003 on January 28, 2004, 09:10:28 AM
Is my code for the layers a good starting point, am i on the right side of the street or am i driving into a head on crash :?:
Title: CAD Setup Routine
Post by: daron on January 28, 2004, 09:22:24 AM
Andre' and Mark, why did I get this:
Code: [Select]
Command: (setq clay (getvar "clayer" "0"))
Error: too many arguments
Error: Function Cancelled.

in testing?

I'm sure Mark just overlooked it, but Andre', look at getvar and setvar. Also, don't forget to test each line of code.
Title: CAD Setup Routine
Post by: amgirard2003 on January 28, 2004, 09:36:59 AM
O.k i see the problem and i fixed it..

it should be like this
Code: [Select]

(setq clay (getvar "clayer"))



I realized what the problem was..

The (getvar) only accepts one arguement and that arguement is the variable you want to get.
Title: CAD Setup Routine
Post by: CAB on January 28, 2004, 09:37:31 AM
Quote from: Daron
Also, don't forget to test each line of code


Andre'

Have you tried the trace process in VLIDE??

Did you have any questions on that?
Title: CAD Setup Routine
Post by: amgirard2003 on January 28, 2004, 09:48:21 AM
Quote from: CAB
Quote from: Daron
Also, don't forget to test each line of code


Andre'

Have you tried the trace process in VLIDE??

Did you have any questions on that?


I'm trying to remember to test each line of code and to do that i've kept the Watch Window open so it reminds me to test..

If Trace is different than Watch, then i have no idea what you're talking about.. never heard about it?

If it's something that is useful and that will help me out, please direct me in the right direction..
Title: CAD Setup Routine
Post by: amgirard2003 on January 28, 2004, 11:35:10 AM
Question for all of you

In the following code that i have

Code: [Select]

(defun newlayers ( / cmd clay) ; defined the function as newlayers with local variables CMD CLAY
  (setq cmd (getvar "cmdecho")) ; set variable cmdecho to cmd for temporary status
  (setq clay (getvar "clayer" )) ; set variable clayer to clay for temporary status
  (setvar "cmdecho" 0) ; set variable cmdecho to 0, to disable commands being echoed to the command line
 
  (command ".layer" "m" "1"    "c"    "1"    ""    "" ; Start Layer command and create the following layers
  ".layer" "m" "2"    "c"    "2"    ""    "" ; ".layers" is the layer command, "m" stands for make
  ".layer" "m" "3"    "c"    "3"    ""    "" ; "1" is the name, "c" is the color, "1" is the color
  ".layer" "m" "4"    "c"    "4"    ""    ""
 ) ; End of the Layer command
  (setvar "clayer" "1") ; set current layer to 1
  (setvar "cmdecho" cmd) ; set cmdecho back to original state with variable cmd
  (setvar "clayer" clay) ; set clayer back to original state with variable clay
  (princ) ; silent exit
) ; end of defun function


How can i apply this part to it..

When you run this code it creates to the following layers.. o.k great..
now after creating these layers i change the color of 2 of the layers and i purge the drawing and it deletes 2 other layers i didn't use...
I then realize "OH CRAP" i need those 2 layers and i re-run the routine to load those 2 layers but i don't want the layers i changed the colors to change??

I assume that i have to apply and IF statement with a variable but i don't know where to begin
Title: CAD Setup Routine
Post by: CAB on January 28, 2004, 12:07:39 PM
ander'

Tracing or Stepping through the code is what I meant and it looks like
you are doing that.

Your other question on avoiding the re-creation of a layer.
something like this will work.

Code: [Select]

  (if (not (tblsearch "layer" "1"))
    (command ".layer" "m" "1" "c" "1" "" "")
  )
  (if (not (tblsearch "layer" "2"))
    (command ".layer" "m" "2" "c" "2" "" "")
  )
  (if (not (tblsearch "layer" "3"))
    (command ".layer" "m" "3" "c" "3" "" "")
  )
  (if (not (tblsearch "layer" "4"))
    (command ".layer" "m" "4" "c" "4" "" "")
  )
Title: CAD Setup Routine
Post by: daron on January 28, 2004, 12:13:38 PM
If I were you, I'd take Keith's layer creater routine and pick it apart. Find out how it ticks. What you can do to test it, is for each variable on the left side of "/" in (defun xxx (var1 var2 var3 / lv lv2 lv3) you can write a setq var1 etc and that value will be read when you test the code.
Title: CAD Setup Routine
Post by: amgirard2003 on January 28, 2004, 12:34:04 PM
I copied Keith Routine and i'm trying to run it to see what it does but it doesn't work.. (err.. too few arguements)

can someone help me out with getting it to work?
Title: CAD Setup Routine
Post by: daron on January 28, 2004, 12:38:44 PM
That's what I was trying to explain. Arguments! You need to somehow supply values to all the arguments (variables) to the left of the /. You can do a setq and set a value for each, or you could do as it seems you've done and run the code  like so: (functionname arg1 arg2 arg3...). All arg's are the value you specify. So, if you want the layer name to be "andre", you specify that in the layer name's argument space. Does that make any sense?
Title: CAD Setup Routine
Post by: amgirard2003 on January 28, 2004, 12:41:26 PM
Thanks Daron.... i get it now...
I'll give it a try...
Title: CAD Setup Routine
Post by: daron on January 28, 2004, 12:46:05 PM
Code: [Select]
(defun mlayer (layer_name aci_layer_color on_off thaw_frz lock_unlk / new_bit layer_list)
  (if (not (tblsearch "LAYER" layer_name))
    (setq layer_list (entget (tblobjname "layer" "0")))
    (setq layer_list (entget (tblobjname "layer" layer_name)))
  )
  (if (= thaw_frz 0)
    (setq new_bit 0)
    (setq new_bit 1)
  )
  (if (= lock_unlk 1)
    (setq new_bit (+ new_bit 4))
  )
  (if (= on_off 0)
    (setq aci_layer_color (- 0 aci_layer_color))
  )
  (setq layer_list (subst (cons 2 layer_name)(assoc 2 layer_list) layer_list))
  (setq layer_list (subst (cons 62 aci_layer_color)(assoc 62 layer_list) layer_list))
  (setq layer_list (subst (cons 70 new_bit)(assoc 70 layer_list) layer_list))
  (if (not (tblsearch "LAYER" layer_name))
    (entmake layer_list)
    (entmod layer_list)
  )
)

Let's look at his code. Load that and on the command line paste or rewrite this:
Code: [Select]
(mlayer "Andre" 6 1 0 0)
You should now have a layer called Andre that is magenta.
Title: CAD Setup Routine
Post by: amgirard2003 on January 28, 2004, 01:33:12 PM
I was screwing up the beginning but it's working now..

let's see how i do on breaking this down

Code: [Select]

(defun mlayer (layer_name aci_layer_color on_off thaw_frz lock_unlk / new_bit layer_list)
  (if (not (tblsearch "LAYER" layer_name))
    (setq layer_list (entget (tblobjname "layer" "0")))
    (setq layer_list (entget (tblobjname "layer" layer_name)))
  )


-Define the function as mlayer and the following arguements..
ex. (mlayer "Andre" 4 6 1 0)
- if the layer doesn't exist then go and copy layer 0 as the background for the new layer to create on, and in the following line change the name of the layer you copied to "Andre".

Code: [Select]


(if (= thaw_frz 0)
    (setq new_bit 0)
    (setq new_bit 1)
  )



check and see if you set the layer to be either frozen or thawed.. if set to 0 then it will stay thawed and 1 will set it to frozen

Code: [Select]


(if (= lock_unlk 1)
    (setq new_bit (+ new_bit 4))
  )


check to see if it will be locked or unlocked.. if set to 0 it will stay unlocked and will return NIL if set to 1 it will lock the layer
Question:  why (+ new_bit 4)??

Code: [Select]


(if (= on_off 0)
    (setq aci_layer_color (- 0 aci_layer_color))
  )


check and see if it will be on or off, if set to 0 it will be OFF if set to 1 then it will be turned on.
Question: why (- 0 aci_layer_color)

Code: [Select]

(setq layer_list (subst (cons 2 layer_name)(assoc 2 layer_list) layer_list))
  (setq layer_list (subst (cons 62 aci_layer_color)(assoc 62 layer_list) layer_list))
  (setq layer_list (subst (cons 70 new_bit)(assoc 70 layer_list) layer_list))


O.k the tricky part for me..
Now it's time to take all the variables and put them together..
take Layer name and add it to the layer_list ("Andre")
take Layer color and add it to the layer_list (cyan or 4)
modify all the new bits ( freeze/thaw , On/Off, Lock/Unlock)

question: Confused on the last one (setq layer_list (subst (cons 70 new_bit)(assoc 70 layer_list) layer_list)) ??

Code: [Select]


(if (not (tblsearch "LAYER" layer_name))
    (entmake layer_list)
    (entmod layer_list)



and the for the final part..
If layer is TRUE and EXIST at the beginning then it will become true and will only be modified (entmod layer_list)
(entmake_list) will make the layer if it's FALSE from the beginning..



So how did i do??  B or B+ :)
Title: CAD Setup Routine
Post by: daron on January 28, 2004, 02:07:09 PM
Do you know where to find the dxf Reference in the help files? Look in there, under Tables and select layer. Study that page a bit and you should have your answers.
Title: CAD Setup Routine
Post by: Keith™ on January 28, 2004, 02:08:08 PM
I would give that a B+ but there are a few minor things that need to be clarified. I will point them out and you will then understand the things you questioned before.
Quote

-Define the function as mlayer and the following arguements..
ex. (mlayer "Andre" 4 6 1 0)
- if the layer doesn't exist then go and copy layer 0 as the background for the new layer to create on, and in the following line change the name of the layer you copied to "Andre".


The last three arguments of this function should only be 0 or 1
The code first checks if the specified layer exists if it does not, then it will grab the contents of layer 0 as a starting point, a template if you will, for the new layer - in this instance "Andre"

Quote

check and see if you set the layer to be either frozen or thawed.. if set to 0 then it will stay thawed and 1 will set it to frozen


To expand upon this a bit, the variable new_bit will hold all of the bitwise values for the layer as defined by DXF code 70, you will need to see the DXF code explanation in the help files for the bit codes. Suffice to say that 1 = freeze

Quote

check to see if it will be locked or unlocked.. if set to 0 it will stay unlocked and will return NIL if set to 1 it will lock the layer
Question: why (+ new_bit 4)??


If the layer is designated to be locked, the bitwise value for a locked layer will be added to new_bit. As before the value of Freeze/Thaw Lock/Unlock as well as a few others we will not be concerned with here are bitwise. The bit for locking happens to be 4. So to lock AND freeze the value would be 4 + 1 or 5 that is why we are adding the 4 to new_bit.

Quote

check and see if it will be on or off, if set to 0 it will be OFF if set to 1 then it will be turned on.
Question: why (- 0 aci_layer_color)


As defined by the program 1 = on and 0 = off, this has nothing to do with the layer actually being on or off, only how we tell what the user wants it to be. The reason for (- 0 aci_layer_color) is that the way AutoCAD determines if a layer is on or off is that the layer color is either a positive number OR a negative number. If the layer color index number is negative the layer will be turned off, to do this, if the user elected to turn off the layer, (on_off = 0) then we subtract the layer index number from 0 effectively giving a negative value and turning the layer off.

Quote

O.k the tricky part for me..
Now it's time to take all the variables and put them together..
take Layer name and add it to the layer_list ("Andre")
take Layer color and add it to the layer_list (cyan or 4)
modify all the new bits ( freeze/thaw , On/Off, Lock/Unlock)

question: Confused on the last one (setq layer_list (subst (cons 70 new_bit)(assoc 70 layer_list) layer_list)) ??


Ok, first we substitute the new layer name layer_name for the old layer name (assoc 2 layer_list) in the layer entity list layer_list and save it back to itself. Then we use the same scenario to substitute the new color for this layer, finally we set the bitwise setting for the frz/thw lck/ulk layer state using the same scenario. Remember that DXF 70 holds the setting for frz/thw and lck/ulk and that is why we modify that setting.

Quote

If layer is TRUE and EXIST at the beginning then it will become true and will only be modified (entmod layer_list)
(entmake_list) will make the layer if it's FALSE from the beginning..


The reason we need this is because if layer "Andre" were to exist in the beginning, then we could not (entmake ...) it, but we could (entmod ...) it, and at the same time if the layer did not exist in the beginning, we could not (entmod ...) it but would have to create it with (entmake ...).

Hopefully this explained it a little better and you have a better understanding of lisp.
Title: CAD Setup Routine
Post by: amgirard2003 on January 28, 2004, 02:29:50 PM
Thanks... that's has cleared up a lot of cobwebs...
I kind of surprised myself, didn't think i would be able to disect
the code... i think i was pretty close...

I wasn't aware of the dxf codes... so that made a lot of things just click..
Title: CAD Setup Routine
Post by: daron on January 28, 2004, 02:40:08 PM
Alright! So, now do you understand how and why to use reusable code and what it means? Remeber, not all modules/functions/reusable code have to have arguments. Those are the easy one's to understand. Do you understand why many will have arguments?
Title: CAD Setup Routine
Post by: SMadsen on January 28, 2004, 02:57:11 PM
..only wives need arguments
Title: CAD Setup Routine
Post by: daron on January 28, 2004, 03:13:53 PM
hehehe
Title: CAD Setup Routine
Post by: Keith™ on January 28, 2004, 03:40:32 PM
And get them they do ...
Title: CAD Setup Routine
Post by: Matt Stachoni on January 28, 2004, 06:32:33 PM
I've done quite a bit of "standards enforcement" programming in (v)lisp, and here are some random ideas that have helped me:

1. Have a plan. Don't try to code everything in one shot and allow yourself to think like a programmer. Think in terms of modules of small functions that work together to solve big tasks. Always break the problem down into smaller units. IOW, one function may set up text styles, one may set up layers, another may set up dimstyles, etc.

I've found it very helpful to write long comments of pseudocode or algorthms in plain text that describe the logic breakdown before writing a single piece of code. I do this even for non-programming tasks. Pretty soon you think like this for everything like making cereal to cutting the grass, e.g.

Open Fridge Door
Take Milk Out
If (= Yes EnoughForCereal), (TestMilk)
  otherwise, (MakeToast)
If (= Ok (TestMilk))
  (MakeCereal)
  ((ThrowOutMilk) (MakeToast))

2. Separate code from data. That is, create a text file of your intended Standards settings in an .ini file or some other text file (the extension doesn't matter).  Make them delimited by space or character. For example, a layer standards file might look like:

0 red continuous plot
A-WALLS yellow continuous plot
A-NOPLOT 37 continuous noplot

etc. Do the same for dimension styles and text styles (each a separate file). For annotation styles, set all heights and size values to plotted sizes.

Each kind fo file may have a different data format. In my dimstyles standards file I use mostly Dimvar names in association lists (e.g., ("DIMBLK" . "_ARCHTICK") because it makes implementing it very easy. For text styles, I used a simple assoc. list based on DXF codes for text Styles (e.g., '(2 . "STYLENAME"). for layers it's a bit more cumbersome because we use layer prefixes then std layer names. But easily handled by code.

The point is, pick a format for the type of data and write code around it to process the file easily. With vlisp's extended functions for handling strings, it's super easy.

3. Create a development environment for yourself. Put all of your code and Standards data files into an \Admin folder tree that only you have read/write access to. Create a parallel \Company folder for everyone else. Develop, test and compile in \Admin, copy the fas/vlx/lsp files to the \Company tree for implementation. Make subfolders for resources, menus, apps, sourcecode, vlx, etc.

Each normal user has their profile Support Files path point to the \Company tree, yours points to \Admin. You are always in development mode, they are always using solid code. You can screw up without torpedoing the entire company.

4. Create very general code functions that process the files. The functions simple read the files in line by line into a big list, then parse the list for the intended fields. Then apply the settings to the layers/dimensions/styles, either through a simple (command "layer") call or through ActiveX.

By doing this you make sure that someone doesn't have to know how to code AutoLISP or VBA to modify the standards. This is important if you get hit by a bus.

Not only that, but it's portable, so you can migrate the same data files to VBA if you want to do so withou recoding the standards themselves.

5. For annot. styles, wrap everything up into a single general function that sets all scale-dependent settings in one shot. If you do annotations in MS, then you can simply execute a function like this (annotsetup "Standards" 96.0) which

a) sets a global LTSCALE size
b) reads the settings for text styles from standards.txt and sets them accordingly,
c) reads the dimensions text file from "standards.dim" and sets up a dimstyle and all child dimstyles

Since we do all annotaiton in MS and use Xrefs extensively, we can get away with using one - and only one - dimstyle per drawing, so all of our dwgs have a dimestyle called ARCHITECT. Each file has one annotation scale; everything is the same except for the all-important DIMSCALE system variable.

3. Wrap everything up into simple cascading menus. I generally don't use Templates because they are tougher to maintain over time, and it's easier to manage a few simple text files that set all standards.

Instead, I have my users start all of their drawings with the same template (acad.dwt) which is "clean" - no layers/dimstyles/text styles. Then they step through two cascading menus - one to load layers, another to set the scale which also sets text/dim styles and ltscale. Since we do Architectural work, the layers pulldown has different entries for loading separate sets of layers (new, demo, existing, RCP, furniture, etc).

Hope it helps to give you ideas.
Title: CAD Setup Routine
Post by: Mark on January 28, 2004, 06:46:09 PM
Excellent piece Matt. I know we can all learn a thing or two by following your advise. Why don't you sign up as a member, I would be glad to have you and your knowledge hanging around TheSwamp. :D
Title: CAD Setup Routine
Post by: CAB on January 28, 2004, 07:38:29 PM
Very good Matt.

I am a one man operation so I use template files with most things set up.
Having separate templates for one or two or three story houses,
One for site and another for details. But I have found that when I decide
to change something I may have to revisit all templates.

Your suggestion would be a lot of work for me initially but I think it would
pay off in the long run even for a one man operation.


Thanks for the info.

CAB
Title: CAD Setup Routine
Post by: Keith™ on January 28, 2004, 08:33:44 PM
Incedently, I used to work at a place where the drawing standards were implemented using code to a point, and also layers. It was a simple process. When you want to load all of the layers, a blank drawing was inserted as an exploded block. Thus the traits of the new block made the required attributes of the drawing. One for linetypes, one for layers, one for textstyles etc ... yes there are files to maintain, just like a template, BUT, the files can be maintained even by a novice. The simple thing being if you want to add or modify a layer, simply change the layer drawing. There was a little more to it than that, but it also allowed us to have different combinations of the same standards for different projects. In other words layer set #1 and texstyle set #3 or layers #2 and textstyles #3 etc...
Title: CAD Setup Routine
Post by: amgirard2003 on January 29, 2004, 09:45:01 AM
I'm glad to see i've attracted quite a bit of attention and input here...
Title: CAD Setup Routine
Post by: amgirard2003 on January 29, 2004, 09:54:10 AM
O.k... let's get back on track here..
Through reading the posts that have been posted and getting
the fact that i should break things down to it's simplest form to make
it easier to work with.

In that case I'm doing the following

With the layers i will make one routine to load the layers
and i will make another to reload them..

Now where do i begin with the reloading..
I'm slowly walking through this process... so give me a little time and i will post any problems that i have.
Title: CAD Setup Routine
Post by: daron on January 29, 2004, 10:39:32 AM
Load and reload? That can be done in one, I'm sure, since, if a layer exists you won't overwrite it, but you may alter its properties. That can definately be a good thing. Now, let's say you take Keith's function for creating a layer. You don't call it alone. Call it in a command line program the way we helped you understand the arguments idea. So, you could either do this:
Code: [Select]
(mlayer "Andre" 6 1 0 0)
(mlayer "Bob" 5 1 0 0)
(mlayer "3" 4 1 0 0)
(mlayer "4" 3 1 0 0)
(mlayer "5" 2 1 0 0)
(mlayer "6" 1 1 0 0)
(mlayer "7" 7 1 0 0)

which is fine, but that can get really large as you input more layers. Another way, and there are many would be to put the elements in a list and use one of the many ways that exist to process lists, i.e. mapcar, foreach... Study the help files on those and ask questions about them.
Title: CAD Setup Routine
Post by: amgirard2003 on January 29, 2004, 10:54:17 AM
Quote from: Daron
Load and reload? That can be done in one


Wouldn't it be simpler for me to do it in 2 parts for right now until i get a clear head as to what i'm doing, and then at that point i could modify it and combine them together..

And one other thing.. adding to the list...
what other functions besides mapcar and foreach should i really be looking at?
Title: CAD Setup Routine
Post by: daron on January 29, 2004, 11:35:24 AM
repeat, while, lambda. The two I originally gave you are the most common and easiest for processing unknown number item lists. Repeat is similar to foreach, but you can designate a fixed number and it doesn't have to process lists. It's also the easiest, IMO, to use. I didn't suggest it, because I think making a list of your layers and properties would be most ideal as well as easy to update.
Title: CAD Setup Routine
Post by: amgirard2003 on January 29, 2004, 11:44:25 AM
I'll run through some Pseudo Code for ya and you can check and see if i'm on the right path.

First create all layers and load them into the drawing.
Next set all the layers to a list for future reference. (reference layer list)

Now when resetting layers set all the current layers in the
drawing to a new list (current layer list).

Now check the (current layer list) to the (reference layer list)
Foreach layer that doesn't exist, re-load the original layer from the (reference layer list).

Does that make any sense to anyone?
and Secondly because i don't know what the possibilities of Autolisp are can you even do something like this or do i have to tweak my thinking?

I appreciate all input on this
Title: CAD Setup Routine
Post by: daron on January 29, 2004, 12:14:29 PM
I suppose you could do that, but what say you a user inadvertantly set a layer that you want green, blue. Running this layer standard routine should be able to set that back automatically. I don't think you need to worry if the layer exists nor do you need a cross-reference list. Just have a list like so
(setq layname '("andre" "bob" "joe" "1" "2" "3'))
(setq laycol '(1 2 3 4 5 6)
in the lisp. You can update the lisp as you need to.
Multi-dimensioned safearrays come to mind, but you aren't ready for those yet. Plus, I think lisp has trouble with those sometimes.
Title: CAD Setup Routine
Post by: amgirard2003 on January 29, 2004, 12:33:48 PM
hmmm......  :?  :?
Title: CAD Setup Routine
Post by: daron on January 29, 2004, 12:57:58 PM
I know, overwhelming.
Title: CAD Setup Routine
Post by: amgirard2003 on January 29, 2004, 01:10:22 PM
yeah tell me about it..
I'm confused as to where to start...
Title: CAD Setup Routine
Post by: daron on January 29, 2004, 01:14:57 PM
Put a list of layernames, colors, linetypes, lineweights, on/off, thaw/frozen, lock/unlock, plot/noplot. That might be the best place to start.
Title: CAD Setup Routine
Post by: amgirard2003 on January 29, 2004, 03:04:37 PM
Finally i have a complete list of all the layers and the characteristics.. :)

Should i first proceed with the first part of the routine... Creating and loading all the layers or should i do something else than what my first idea was.
Put all my layers in this code?
Code: [Select]

(defun newlayers ( / cmd clay)
  (setq cmd (getvar "cmdecho"))
  (setq clay (getvar "clayer" ))
  (setvar "cmdecho" 0) ;

 
  (command ".layer" "m" "1" "c" "1" "" ""
  ".layer" "m" "2" "c" "2" "" ""
  ".layer" "m" "3" "c" "3" "" ""
  ".layer" "m" "4" "c" "4" "" ""
 )
  (setvar "clayer" "1")
  (setvar "cmdecho" cmd)
  (setvar "clayer" clay)
  (princ)
)


I know i'm asking for a lot of direction when i should be trying to figure out what i should do next (and believe me i do try to figure things out on my own) but i'm tryin to get an understanding of what you guys are thinking when you write a routine. Where you all start, what are things you think about and so on... I don't have that programmers mentality like i know a lot of you all have so i know i miss a lot of things... Things that might be starightforward to you are completely ass backwards to me?

I appreciate the patience to the ones that have participated in this thread...
It does mean a lot.. i know a lot of places i wouldn't have lasted this long.
Title: CAD Setup Routine
Post by: daron on January 29, 2004, 03:37:56 PM
Well, here comes #1600. Are you actually planning on use 1 2 3 4 etc for layer names? If so, read this (http://www.theswamp.org/phpBB2/viewtopic.php?t=634&start=0). Otherwise, let's start with... Post these layer names and properties, if you will. One thing I notice in your code is that you get the current layer ("clayer") variable only to set the clayer to one and then set the layer to the previous layer state. What's the point to that? Also, if you're setting standards and these things happen when opening any drawing, you need to consider things like the speed of the routine. As well, you most likely don't have to reset the layer, since it wasn't something anybody was using previously. The drawing was just opened.

Here's an example: My current employer released some "standards" that anytime anybody opens any drawing a large load of command line driven code gets "published". We see all kinds of movement of our drawing, blocks being inserted and deleted and the entire drawing being zoomed to extents. What if we were zoomed to a specific place when we were last in the drawing and wanted to open it the next day where we left off? Needless to say, this whole company "standard" is quite annoying and slow. Did I mention SLOW before. That was the whole point, here. The code. I've heard many people say, "What does the speed matter? Computers are much faster these days. You're worrying about milliseconds?" Well, compound all those milliseconds. I saw these problems on other workstations I loaded these "standards" on and decided to leave it off of mine. I can load 5 drawings before anybody else can load one, because of these "standards". Anyway, what I'm trying to get at, is your code above might work, and is good practice, but it will become very inefficient as it grows. For an example of what I mean, look into this (http://www.theswamp.org/phpBB2/viewtopic.php?t=164) and I believe I gave you this one before, but take notice of the race that goes on here. (http://www.theswamp.org/phpBB2/viewtopic.php?p=336#336) Eventually, if you process enough layers, you'll end up crashing every computer on startup if you use command.
Title: CAD Setup Routine
Post by: pmvliet on January 29, 2004, 06:54:18 PM
I will jump in on page 8! I agree with Daron in the fact that you are going to be adding a tremendous amount of data/computer time to files that may not necessarily want it. I would suggest to break it out by area of concern and have various routines to set certain items.
have one routine for fonts, one routine for dimension styles, one routine for printing page set-ups. These could be invoked by command or buttons via a toolbar.

Something not mentioned in this thread it are system variables and search paths. These are big issues that can make or break consistency for a project. Does everyone have textfill on, is everybody looking at the same colortables, same fonts etc...

my thoughts,
pieter
Title: CAD Setup Routine
Post by: Keith™ on January 29, 2004, 08:53:18 PM
Daron,  as I previously posted, my last employer used around 120 layers for their standards, and rather than create each layer automatically when the drawing opened, we simply created a blank drawing with all of the layers for each standard, then based on certain criteria we sinply used ...

Code: [Select]

(command "-insert" "*layers" 0,0 0 "")


Not to pull the plug on anything, but it seemed to work flawlessly.
Title: CAD Setup Routine
Post by: amgirard2003 on January 30, 2004, 09:08:04 AM
well everything has become too overwhelming to me.. :(
I've come to the point where i don't know what i'm doing..
I don't even know what to write or even think as to what code i need for this to work. I can't even think my way through a simple routine..
 :x  

I'm gonna have to slow this train down and start taking this one line at a time, instead of one concept at a time. :?

I'll be posting my homework and that was understanding
Foreach, Lambda, Mapcar, Repeat and while..

I'll post for your reviews..
Title: CAD Setup Routine
Post by: amgirard2003 on January 30, 2004, 10:07:46 AM
I'm submitting my homework for grading.

Foreach: Fist off it's a function that works with lists.
It steps through the list, assigns each and member of the list to the name and evaluates each one individually until the end of the list.

ex: (foreach andre '(a b c)(print andre)
this would print out
a
b
c

Mapcar: allows you to perform a function on each element of a list.

(setq '(a 1 2 3 4 5 ))
(mapcar '1+ (list a))

This will add 1 to each element of the list
the result would be (2 3 4 5 6)


While: Works as like a loop... saying while some thing is true, keep doing it until it becomes False.

Repeat: Works as a loop using a counter... So if you say to repeat some 10 times, it will repeat it 10 times.

Lambda.... confused on this on... :?  :?
Title: CAD Setup Routine
Post by: Mark on January 30, 2004, 10:10:13 AM
>Lambda.... confused on this on...
Don't feel bad, it's not an easy one. <G>
Title: CAD Setup Routine
Post by: CAB on January 30, 2004, 10:21:34 AM
Take a look at this Lambda (http://theswamp.org/phpBB2/viewtopic.php?t=340) info.
Title: CAD Setup Routine
Post by: daron on January 30, 2004, 10:52:05 AM
Quote from: amgirard2003

ex: (foreach andre '(a b c)(print andre)
this would print out
a
b
c

Answer this! What is the function on the value andre?
Quote
(setq '(a 1 2 3 4 5 ))
(mapcar '1+ (list a))
This will add 1 to each element of the list
the result would be (2 3 4 5 6)

That is slightly wrong. Should be set as (setq a '(1 2 3 4 5))
Otherwise, you're right. You don't need to (list a) because it's already a list. Answer this! What's the difference between '(1 2 3 4 5 b) and (list 1 2 3 4 5 b). Set b to any value. example: (setq b ("something here"))
Quote

While: Works as like a loop... saying while some thing is true, keep doing it until it becomes False.

Explain what you might to to set something as T and within your loop what you might do to change it to nil.

Quote

Repeat: Works as a loop using a counter... So if you say to repeat some 10 times, it will repeat it 10 times.

Repeat is a counted loop i.e. repeat 10 ... will repeat its items 10 times as you say. Answer this: How would you set this for an indeterminate "array" of objects? Let me guide you to the answer of that one. Set a variable for a selection set using ssget. Select some objects. What's the Selection Set LENGTH? That will allow you to set the indeterminate repeat.
Quote

Lambda.... confused on this on... :?  :?

Like Mark said, it's a tough one. I, myself need to find the time to test this one. I've seen it in action and have used it, but am by no means a good user of it. I wouldn't even worry about it at this level. I just threw it out, because you asked.


Challenges! Create a selectionset of objects and change all their layers to a test layer. Functions to use: ssget, sslength, repeat, ssname, entget, cdr, assoc. Then, use filters from the ssget help file to select all elements in a drawing, then filter out all but a specified layer and change the layer name to the above. The second challenge should only require the modification of the ssget sub.

When you've grasp that concept, we'll move to while. We'll save foreach, mapcar and lambda for another challenge.
Title: CAD Setup Routine
Post by: Matt Stachoni on January 30, 2004, 11:15:04 AM
amgirard2003,

Back to your original intent, here's some pseudo code to help you break down the layer loading task.

First, I again strongly encourage you to put the layers and their intended proprerties in a text file instead of a DWG file. While it may seem that DWG allows easier changes to standards, that, IMHO is a real problem (i.e., people can fiddle with it). Also, stuff tends to cling inside of DWG files that can then be passed down stream. You don't want to inadvertently drag blocks or other stuff not related to the problem at hand. Text files are fast to create and easy to manage. Again, think like an application developer and isolate your work to a single set of simple tasks.

I would rather have my users build the drawing up from zero instead of starting with everythjing and whittling it down.

1. We first figure out a format for the layer ASCII file. I would use a written list, because it's super easy to process in LISP. Also you can use comments using ";" as usual and are evaluated as nil by (read):

;; layer.std
;; list format:
;;("Lname" ColorNum "linetype" "Plot/NoPlot")
("0" 3 "continuous" "plot")
("A-WALL" 4 "continuous" "plot")
("NoPlot" 6 "continuous" "noplot")
etc.

Note that ColorNum is an integer, not a string. This makes it easier to later use an (entmake) expression to create the layer, using ColorNum as an integer without having to convert it from a string.

2. Now we need a generic function that :
 a. tests for existence of a file name (passed as an argument)
 b. Reads each line in the file
 c. If it evaluates to a list type, save that list, and add it to a master list.
 d. Return a list of lists

Formatting the ASCII file in this manner means that you can use the (read) function efficiently. (read) interprets the list sring as a true list, and reads the comments as nil. This is of course looped until the eof.

Some code to help get you started:

(defun lyr:ReadFile (fname / fp f fline flist)
  ;; read a text file, return a list of the contents
  (if (setq fp (findfile fname))
    (progn
       (setq f (open fp "r"))
       (while (setq fline (read-line fline))
         ; use (read) to convert string data as LISP data
         (setq fline (read fline))
         ;; test the data - is it a true list?
         (if (= 'LIST (type fline))
           ;; add it to the beginning of the return list (flist)
           (setq flist (cons fline flist))
         )
       )
       (close f)
     )
     (prompt (strcat "\nError: File " fname " does not exist."))
  )
  ; return list in order that it was read
  (reverse flist)
)

Once you have the list of layers to add to the drawing, you would feed that list to a "create layer" function that would
1. Loop through each layer list "record"
2. Test to see if the layer name exists
3. If it doesn't exist, create the layer with the properties.
4. If it does exist update the layer with the std. properties.

I would suggest resetting the existing layer parameters to the proper "standard" properties given in the list to help enforce standards.

If you are multidiscipline and/or want different standards for different type of drawings, you can make many layer standards files and call the single function with the appropriate file name as the parameter. This granularizes your drawing's layers, and gets you away from loading every single layer in you total standards at once (again, building up the drawing). You can pile on several layer sets in one shot or have the user load then separately as they wish.

Implementing this in a pull down menu seems to be the easiest and most efficiwent solution that I can think of.

-Matt
Title: CAD Setup Routine
Post by: daron on January 30, 2004, 11:34:50 AM
Wow Matt. That's awesome. That opens the door to a different way of thinking.
Title: CAD Setup Routine
Post by: amgirard2003 on January 30, 2004, 11:54:14 AM
Boy!!.. did i open a big can of worms on this one. :shock:

O.k to Daron's questions..

1.
Quote

ex: (foreach andre '(a b c)(print andre)
this would print out
a
b
c

Answer this! What is the function on the value andre?


O.k you got me really confused on this one.. I've read and re-read this one over and over and i don't know if i got it though but let's give it a whirl..
The more i've been playing around with this the more i get confused..

I'm taking a wild guess... The Function on the value andre is Foreach..

2.
Quote

(setq a '(1 2 3 4 5 ))
(mapcar '1+ (list a))
This will add 1 to each element of the list
the result would be (2 3 4 5 6)

Answer this! What's the difference between '(1 2 3 4 5 b) and (list 1 2 3 4 5 b). Set b to any value. example: (setq b ("something here"))


I've played around with this one and noticed one thing and through some reading found the following:

when '() the list inside is quoted and not evaluated.
when (list) the list inisde is evaluated.

So when
Code: [Select]

(setq b "100")
(setq a '(1 2 3 4 5 b)
(mapcar '1+ (1 2 3 4 5 b)


because the list is quoted
if it were like this
Code: [Select]

(setq b "100")
(setq a (list 1 2 3 4 5 b)
(mapcar '1+ (1 2 3 4 5 b)


the result would be (1 2 3 4 5 100) because the list is being evaluated.

3.
Quote


While: Works as like a loop... saying while some thing is true, keep doing it until it becomes False.


Explain what you might to to set something as T and within your loop what you might do to change it to nil.


Alright let's just try this...ummm you could use conditionals or a counter
you could set a counter to 10 (true), so while the total is below 10 keep looping..once the total reaches 11 it crashed and the counter becomes (false)

4.
Quote
Repeat: Works as a loop using a counter... So if you say to repeat some 10 times, it will repeat it 10 times.

Set a variable for a selection set using ssget. Select some objects. What's the Selection Set LENGTH?


The LENGTH of the selection set is the number of entities you selected
so if you set a limit of 10 within ssget... repeat will only work until you reach 10. If ssget is set with no limit.. then you have no limits as to how many entities you can select.

Your challenge... hmmm that will take some time..

I'll get back to you when i run into some trouble..(which probaly won't take too long)

Haven't learned any of the functions you mentioned.. so i'll have to read about them and find out more on what i have to do...
Title: CAD Setup Routine
Post by: daron on January 30, 2004, 12:17:12 PM
1) I want to know if you understand the purpose of the argument after foreach.

What I'd like to see is an example of these. You can tell me the answers all day, but until you show some code, you'll never be able to actually do the programming. I've been reading a lot of books lately on web programming. I've read one on javascript. I fully understand it, but because I haven't attempted to write any, I have no idea how to begin. Does that make sense? Show us you can write the code now, not just understand the functionality of it.

2) Good understanding. It can be more difficult though.

3) almost. The counter will reach 11, but while will stop processing it and continue on with the code that follows while. It does not crash, it ends.

4) Did you try length on the value of a sssget. I did, I got an error. You're close with length, but you need a slightly different length sub. Have a look at sslength. Test both. Post the code and post the answers. Don't set repeat to a specific value. Use the variable that contains the sslength of the ssget. Then, it will repeat for as many object are in the ssget you selected.

As far as the other functions I mentioned, they are all needed in order to do the challenge I set up. I listed them in order of importance.
Title: CAD Setup Routine
Post by: amgirard2003 on January 30, 2004, 12:31:14 PM
Quote from: Daron
4) Did you try length on the value of a sssget. I did, I got an error. You're close with length, but you need a slightly different length sub. Have a look at sslength. Test both. Post the code and post the answers. Don't set repeat to a specific value. Use the variable that contains the sslength of the ssget. Then, it will repeat for as many object are in the ssget you selected.


How did you do that?
Title: CAD Setup Routine
Post by: Matt Stachoni on January 30, 2004, 12:34:02 PM
Quote from: amgirard2003
well everything has become too overwhelming to me.. :(
I've come to the point where i don't know what i'm doing..
I don't even know what to write or even think as to what code i need for this to work. I can't even think my way through a simple routine..
 :x  


Aas you see, there's a lot of difference between reading how a language works and actually using it. It may take a long time to initially "get it" but that's only temporary - you will become an expert programmer if you work through the initial frustration.

First, I would suggest that you pick up Roy Harkow's book "Essential AutoLISP" if you can find it. It stresses the low-level understanding of (eval) which is used in every single AutoLISP expression behind the scenes. Once you understand that, and an inner working of what lists are (as an assembalege of cons constructions), you really can start whipping through code like a demon.

It also runs through the functions step by step in a linear fashion until you really understand how to use them.
Title: CAD Setup Routine
Post by: daron on January 30, 2004, 12:38:27 PM
Quote from: amgirard2003
Quote from: Daron
4) Did you try length on the value of a sssget. I did, I got an error. You're close with length, but you need a slightly different length sub. Have a look at sslength. Test both. Post the code and post the answers. Don't set repeat to a specific value. Use the variable that contains the sslength of the ssget. Then, it will repeat for as many object are in the ssget you selected.


How did you do that?


(setq ss (ssget))
(length ss)
Answer: Error: blah blah blah.
(sslength ss)
25

(repeat (sslength ss) or set it to a variable.
Title: CAD Setup Routine
Post by: amgirard2003 on January 30, 2004, 12:42:21 PM
Quote from: Daron

What I'd like to see is an example of these. You can tell me the answers all day, but until you show some code, you'll never be able to actually do the programming. I've been reading a lot of books lately on web programming. I've read one on javascript. I fully understand it, but because I haven't attempted to write any, I have no idea how to begin. Does that make sense? Show us you can write the code now, not just understand the functionality of it.


That is my problem... I don't know how to write the code..
this is the frustrating part to all of this.. i understand the concepts but i have no clue where to start or anything..
When i look at the syntax for (foreach name list [expr]) this doesn't tell me anything... i don't know what i'm looking at..
it's all chinese to me..

So when i'm told to write the code to a problem... I look at that scratch my head and say "yeah right" cause i don't know where to begin..

Like i've mentioned it many times before i have no prgramming background, none, zip, nata... so to structurally put a routine together i have no idea.

 :(
i sense the patience with some people is growing thin..
Title: CAD Setup Routine
Post by: daron on January 30, 2004, 01:30:28 PM
Code: [Select]
(setq ss (ssget))
(setq loop (sslength ss))
(setq count 0)

(repeat loop
     (setq ename (ssname ss count))
     (setq elist (entget ename))
     (setq layname (assoc 8 elist))
     (setq mod (entmod (subst (cons 8 "Test") layname elist)))
     (entupd ename)
     (setq count (1+ count))
)

Test these one line at a time. Don't test repeat. Test each line in repeat. I left some things out of my original list. This should work.

Patience growing thin? No! We've all been there. My personal fear is that I've thrown too much at you at one time.
Title: CAD Setup Routine
Post by: amgirard2003 on January 30, 2004, 01:45:42 PM
I created a bunch of line in a new drawing...
I loaded all the code and put a breakpoint and added variables to a watch window.
when i step into the code i see ss equal the amount of line i picked in the drawing, next step i see loop equal the length of ss, the number of members in the selection set.
next is to set the count at 0

when i step into Repeat it's saying to repeat the amount of times loop is equal to... when it goes to the next line it crashes..
Title: CAD Setup Routine
Post by: daron on January 30, 2004, 01:50:01 PM
Sorry, try it now. I entupd to the wrong item and got ssname wrong. ss comes before the count.
Title: CAD Setup Routine
Post by: amgirard2003 on January 30, 2004, 01:59:18 PM
I'm confused with the count part in the code??
i don't understand how it makes the code repeat itself... i don't see the relationship between loop and count.
Title: CAD Setup Routine
Post by: Keith™ on January 30, 2004, 02:22:45 PM
The relationship between loop and count are as follows:

loop is a variable that holds the number of items in the selection set, the name has absolutely nothing to do with the fact that it loops. It could have just as easily been called X

count is a variable that holds the number of items already processed, and could also be called something else.

As a variable, you can use ANY name except those reserved by the system and names with certain characters in them.

To imagine this a different way...
Code: [Select]

;we are saving the selection set in SS
(setq ss (ssget))  
; we are setting the value of LOOP to the number
; of items in the selection set
(setq loop (sslength ss))
; we are initializing count at 0
; because we have not processed anything yet
(setq count 0)

;Now lets suppose you selected 5 items
;the interpreter sees ..
;repeat this code 5 times
     (setq ename (ssname ss 0))
     (setq elist (entget ename))
     (setq layname (assoc 8 elist))
     (setq mod (entmod (subst (cons 8 "Test")layname elist)))
     (entupd ename)
     (setq 1 (1+ 0))
     (setq ename (ssname ss 1))
     (setq elist (entget ename))
     (setq layname (assoc 8 elist))
     (setq mod (entmod (subst (cons 8 "Test")layname elist)))
     (entupd ename)
     (setq 2 (1+ 1))
     (setq ename (ssname ss 2))
     (setq elist (entget ename))
     (setq layname (assoc 8 elist))
     (setq mod (entmod (subst (cons 8 "Test")layname elist)))
     (entupd ename)
     (setq 3 (1+ 2))
     (setq ename (ssname ss 3))
     (setq elist (entget ename))
     (setq layname (assoc 8 elist))
     (setq mod (entmod (subst (cons 8 "Test")layname elist)))
     (entupd ename)
     (setq 4 (1+ 3))
     (setq ename (ssname ss 4))
     (setq elist (entget ename))
     (setq layname (assoc 8 elist))
     (setq mod (entmod (subst (cons 8 "Test")layname elist)))
     (entupd ename)
     (setq 5 (1+ 4))


Note that I replaced LOOP and COUNT with numbers and showed HOW they change.

LOOP tells the program how many times to run and COUNT tells the program how many have already been processed, keeping in mind that the first item is always 0, therefore when item #4 is processed 5 have actually been processed.
Title: CAD Setup Routine
Post by: amgirard2003 on January 30, 2004, 02:47:54 PM
Well it's that time,
Have a good weekend all and i'll be back on Monday, hopefully with a clearer head....
Daron i'll work on the homework over the weekend and i'll let you know how i do on monday.. I won't copy from anyone else.. It'll be my own work..

Thanks for all be patient with me.

See yas monday..
Title: CAD Setup Routine
Post by: daron on January 30, 2004, 02:58:43 PM
it's okay if you take someone else's code. Just test it and study the subs in the code to find out how they work and why. Then try altering the code to see what the result is. By getting errors or different things happen than the original result, you'll start to see and understand how to manipulate the function to suit your needs. You'll also learn how to write the code that way.
Title: CAD Setup Routine
Post by: CAB on January 30, 2004, 04:28:09 PM
Perhaps a change in the variable names will help.

Code: [Select]
(defun c:test ()
  (setq ss (ssget))
  (setq #_of_objects_in_ss (sslength ss))
  (setq pointer 0);; 0 because ss pointer is 0 through (- length 1)

  (repeat #_of_objects_in_ss ;; do this for each object in ss
    (setq ename (ssname ss pointer)) ; get object from set
    (setq elist (entget ename))
    (setq layname (assoc 8 elist))
    (setq mod (entmod (subst (cons 8 "Test") layname elist)))
    (entupd ename)
    (setq pointer (1+ pointer)) ; increment pointer to next object
  )
)
Title: CAD Setup Routine
Post by: daron on January 30, 2004, 04:54:13 PM
Beautiful guys, but he won't learn until he tries to break it.
Title: CAD Setup Routine
Post by: amgirard2003 on February 02, 2004, 08:25:06 AM
Well i've been looking at the code that you guys have posted and i think it's slowly sinking in..

I'm tryin to get the code to change the linetype but it's not working

i changed the 8 to a 6 and change layname to ltpname

Code: [Select]

(setq ss (ssget))
(setq loop (sslength ss))
(setq count 0)

(repeat   loop
     (setq ename (ssname ss count))
     (setq elist (entget ename))
     (setq ltpname (assoc 6 elist))
     (setq mod (entmod (subst (cons 6 "hidden") ltpname elist)))
     (entupd ename)
     (setq count (1+ count))
)


I know at first it won't work when you start a new drawing... but after loading all the layers it won't change the the linetype?
Title: CAD Setup Routine
Post by: Keith™ on February 02, 2004, 08:55:10 AM
There are a couple of things you need to know about the linetype setting on entities. You are indeed on the right track for the linetype DXF code, BUT, if you look a little closer to the DXF reference material you will see that DXF 6 (i.e. linetype) is OPTIONAL and will only be included if the entity linetype is something other than BYLAYER, soooo....

The code you have posted with the variable ltpname IF the linetype is set as BYLAYER, the code will fail because DXF 6 will not exist in a BYLAYER linetype entity, therefore you will need to have a conditional operation after extracting DXF 6 from elist

Code: [Select]

(if (= nil ltpname)
     (setq mod (entmod (append elist (list(cons 6 "hidden")))))
     (setq mod (entmod (subst (cons 6 "hidden") ltpname elist)))
)


Notice that I used APPEND to stick the DXF code (after making it a list) to the end of the entity list. This will ensure that the DXF code 6 is in the entity list.

In other DXF codes where the value is optional, you will need to do a similar bit of code to make the list valid. Since DXF 6 does not exist in elist, you cannot substitute it.

Also, remember that the linetypes you want to set MUST be loaded BEFORE you set the entity to that value, otherwise the entmod will fail.

Does this make sense?
Title: CAD Setup Routine
Post by: amgirard2003 on February 02, 2004, 09:18:31 AM
Code: [Select]

(setq ss (ssget))
(setq loop (sslength ss))
(setq count 0)

(repeat loop
  (setq ename (ssname ss count))
  (setq elist (entget ename))
  (if (= nil linetype)
    (setq mod (entmod (append elist (list (cons 6 "hidden")))))
    (setq mod (entmod (subst (cons 6 "hidden") linetype elist)))
  )
  (entupd ename)
  (setq count (1+ count))
)


here's the code that i worked with and i worked the "if" from Keith's post..
Title: CAD Setup Routine
Post by: daron on February 02, 2004, 10:02:36 AM
Did it work? Are things starting to click?
Title: CAD Setup Routine
Post by: amgirard2003 on February 02, 2004, 10:12:19 AM
yupe it works ...

I would like another homework question that i can try and solve...
Title: CAD Setup Routine
Post by: daron on February 02, 2004, 10:27:20 AM
Study the ssget function and try out some of the filter types. Post attempts and results. Here's one.
(setq blocks (ssget "x" (list (cons 66 1))))

Also, while we're on entity selection, you might have a look at entsel and nentsel.
Title: CAD Setup Routine
Post by: Keith™ on February 02, 2004, 11:21:43 AM
I'll even ask a bonus question for your assignment ...

When wanting to select a single object using running osnap points, what would be the preferred selection function?

A. SSGET
B. ENTSEL
C. NENTSEL

The answer is not quite as simple as it seems, but the answer is in the help file.
Title: CAD Setup Routine
Post by: amgirard2003 on February 02, 2004, 11:56:59 AM
Quote from: Daron
Study the ssget function and try out some of the filter types. Post attempts and results. Here's one.
(setq blocks (ssget "x" (list (cons 66 1))))


Can someone explain what the 66 dxf code stands for...
It says "entities follow flag".. that doesn't tell me anything..

(cons 66 1) what does this mean?
Title: CAD Setup Routine
Post by: daron on February 02, 2004, 12:06:37 PM
Do you have any attributed blocks? The only thing that example picks up is blocks with attributes. It is only an example.

The above example could've been written as:
(setq blocks (ssget "x" '((66 . 1))))

So, (cons 66 1) creates a dotted pair.
Have a look at
(entget (ssname (ssget "x" '((66 . 1))) 0))

Notice any similarities? 66 is the dxf value and 1 is a boolean stating that this procedure only will collect items containing attribute info.
Title: CAD Setup Routine
Post by: Keith™ on February 02, 2004, 12:08:33 PM
DXF 66 is used exclusively for complex entities, and currently the only ones I can think of are old style polylines, 3dpolylines and blocks with attributes.

Essentially if DXF 66 is anything other than 0, there is a subentity that can only be accessed via (entnext base_entity_name) where base_entity_name is the entity name of the selected entity.

For example ...

Code: [Select]

(setq ename (car (entsel))) ; grab entity
(if (/= (cdr (assoc 66 (entget ename))) 0) ;if complex entity
 (setq nextent (entnext ename));get sub entity
)


Once you understand why the following does not work, you will understand the complex entities.

Code: [Select]

(ssget "x" '((0 . "VERTEX")))
(ssget "x" '((0 . "ATTRIB")))


Good luck
Title: CAD Setup Routine
Post by: amgirard2003 on February 02, 2004, 01:07:26 PM
Quote from: Keith
I'll even ask a bonus question for your assignment ...

When wanting to select a single object using running osnap points, what would be the preferred selection function?

A. SSGET
B. ENTSEL
C. NENTSEL

The answer is not quite as simple as it seems, but the answer is in the help file.


Alright...I've been fumbling around with this one for awhile...
After reading through the help back in forth between all 3 and checking other info i've come to the answer that i think C is the appropriate choice.
The reasoning...hmmm...SSGET i feel would be used more for groups of objects. NENTSEL work just like ENTSEL but return a different list, than what ENTSEL would..NENTSEL is works with blocks while ENTSEL doesn't..
You can add in keyword function to select osnap points.
Title: CAD Setup Routine
Post by: amgirard2003 on February 02, 2004, 01:33:49 PM
Quote from: Keith
Code: [Select]

(ssget "x" '((0 . "VERTEX")))
(ssget "x" '((0 . "ATTRIB")))


Good luck


SSGET doesn't work with complex entities..
ENTSEL or NENTSEL must be used with blocks or polylines etc.
Title: CAD Setup Routine
Post by: daron on February 02, 2004, 01:47:45 PM
ssget gets the selected object(s). You must step through the items. ssget can work with complex entities, but it's not the easiest thing to do. Take a look at (ssget ":N"). Read the help file on it, don't test it. Ssnamex is needed for that one and we don't need to go there at this point. Entsel works on blocks, it just selects the entire block, just like ssget except you only get one stab at it. nentsel is similar to entsel in that you only get one stab at it, but it handles complex entities. Nentsel gives you more info, like you said, but what is that info? One of the four lists it puts out is the point at which it was selected. Another is the object within the block (nested). Let's stay focused on the filtering capabilities of ssget for now. What is the "x" I put in my example above for? Try this example out: (ssget "x"). What is selected? Then, why does (ssget "x" '((8 . "0"))) get only objects on the zero layer, if there are any?
Title: CAD Setup Routine
Post by: amgirard2003 on February 02, 2004, 01:55:57 PM
Quote from: Daron
Let's stay focused on the filtering capabilities of ssget for now. What is the "x" I put in my example above for? Try this example out: (ssget "x"). What is selected? Then, why does (ssget "x" '((8 . "0"))) get only objects on the zero layer, if there are any?


(ssget "x") the x means everything in the drawing database.
(ssget "x" '((8 . "0")))  the '((8 . "0"))) is recognized as a filtes list... you are telling the function to look for everything on layer 0.. 8 is the dxf code for layer.

Everytime i seem like i'm gonna make a few steps forward.. BAM i take a blow and i'm 10 steps back.
Title: CAD Setup Routine
Post by: daron on February 02, 2004, 02:20:05 PM
Step forward. That sounds good. What's this doing?
(ssget ":S")
Title: CAD Setup Routine
Post by: amgirard2003 on February 02, 2004, 02:36:13 PM
Quote from: Daron
Step forward. That sounds good. What's this doing?
(ssget ":S")


Allows one single selection only..
So to only allow one object to be picked.
Title: CAD Setup Routine
Post by: Keith™ on February 02, 2004, 02:43:45 PM
Actually that is NOT the correct answer, try posting the code in the AutoCAD command line and see what happens. This is a perfect example of how the help can be misunderstood.
Title: CAD Setup Routine
Post by: daron on February 02, 2004, 02:50:04 PM
Similar to entsel, but you're only half right. Try it while selecting an object and then try it while selecting the blank screen to cross objects. What happened in each case. Don't give me help file answers. Give your tested answers. Then, what's the difference between:
(ssget "x" '((8 . "0"))) and
(ssget '((8 . "0")))

I'm not trying to go in circles here. I'm trying to familiarize you with one sub at a time. When I feel you're comfortable with it, we'll open it up. I know this is slowing you down a bit from your intended purpose, but I feel it should help you understand how to begin testing things and how to write code. So, I want you to break this down a bit. Are you using the vlide? Do you get popups when you test the code?
Title: CAD Setup Routine
Post by: amgirard2003 on February 03, 2004, 08:06:56 AM
Quote from: Daron
Similar to entsel, but you're only half right. Try it while selecting an object and then try it while selecting the blank screen to cross objects. What happened in each case.


(ssget ":S")

When I used the option to select one object, it only allowed me to select one object only, when i used the crossing window, even though the help says "one selection only" it selects all that was in the crossing window.

(ssget "x" '((8 . "0")))

When I used the "x" it selects everything in the drawing that is defined in the filter list (8. "0")

(ssget '((8 . "0")))

When I used a quote it allowed me to select multiple objects.. The reasoning i think this happened is because with the ' it is defining a list.. so when i'm selecting objects, I'm really creating a list of objects.

I'm using vlide with a watch window and i added the variables that i'm using during the test to see what the results are after each line..
As far as pop ups... don't know what you mean by that?
Title: CAD Setup Routine
Post by: daron on February 03, 2004, 10:06:52 AM
pop ups! (http://www.theswamp.org/super.fusion/Tutorials/Vlide%20Editor%20Tutorial/Inspect%20list.JPG)
Poor quality, but in the vlide type (entsel), inspect it and pick an object. You should see this list. That's what I mean by popup. Why I'm asking is that you can double click the
Quote
When I used a quote it allowed me to select multiple objects.. The reasoning i think this happened is because with the ' it is defining a list.. so when i'm selecting objects, I'm really creating a list of objects.

Not quite. "x" is the reason you either select or don't select objects. "x" is the filter for selecting everything in the database. By not putting it there, the computer waits for the user to select objects. '((dxf_value . "property")) is the filter that tells autocad that only objects of this type may be selected.

Now that we have that ironed out, I'll let you experiment on your own for the rest of that subs functions. Let's take a quick look at how to get an entity list with either ssget or entsel:
(entget (ssname (ssget) 0))
(entget (car (entsel)))
Ssget by itself will give you a pickset containing an array of objects. Each array, and I use the term loosly here, contains an object name and an entity name. If you inspect ssget and double-click an array in the popup, you'll get a small group of properties about that object. That list really doesn't do much for us. Try (ssname (ssget) 0) and select one item and enter. You should see a similar popup. This is the contents of each item in your selection set, regardless of how many objects you select. You'll also notice that it starts with 0. Let's open this up a bit more. You now have a single object from the selection set. Inspect the entget procedure above. You should end up with a array of lists that look like this: [1](1 . "INSERT") etc. This is your dxf values and properties for the given object.

Now look at entsel. By itself you should get a popup similar to the image above. Two items in this list. The entity name and a set of coordinates. These coordinates are the point that you just picked. The entity name is the same as the ssget, except if you pick it you don't get any more information. I've given you a lot to think about here, so, a simple challenge. Why in the entsel code above do I use car? What is car, cadr, caddr & cdr? There are many more of these, but I wouldn't worry about them at this point.
Title: CAD Setup Routine
Post by: amgirard2003 on February 03, 2004, 11:44:38 AM
Quote from: Daron

(entget (ssname (ssget) 0))
(entget (car (entsel)))
a simple challenge. Why in the entsel code above do I use car? What is car, cadr, caddr & cdr? There are many more of these, but I wouldn't worry about them at this point.


In the code above you used the car do get the first element of the object that you pick... First element being the entity name.
Car: Returns the first element of a list
ex. you have a coordinate list of (setq a (list 10 20 0)
(setq b (car a))

This will return 10, as 10 is the first element in the variable a which was defined as a list.

Cadr: Returns the second element of a list
Using the same example from above.
(setq a (list 10 20 0))
(setq b (cadr a))

This will return 20, as 20 is the second element in the variable a which was defined as a list.

Cdr: Returns the second and remaining elements of a list
Still using the same example.
(setq a (list 10 20 0))
(setq b (cdr a))

This will return 20 0

Caddr: returns the third element of a list.
(setq a (list 10 20 0))
(setq b (caddr))

This will return 0
Title: CAD Setup Routine
Post by: daron on February 03, 2004, 11:56:46 AM
Good, so you comfortable with using those? Entget? Are you comfortable with this? How to use it and when? Are you comfortable with ssname and how to use it and why? If not, let's dig in, otherwise, we can move on to collecting and manipulating dotted-pair elements in a list.
Title: CAD Setup Routine
Post by: amgirard2003 on February 03, 2004, 11:59:03 AM
Yeah i think i feel comfortable with everything so far...
If i run into some trouble i'll be sure to post... but overall i feel it's sinking in...
Title: CAD Setup Routine
Post by: daron on February 03, 2004, 12:08:28 PM
Let's take a look at the entity list that you should've gotten using entget. How do you get an item out of the list? How do you put an item into the list? How do you change the properties of an item in the list? When we get this nailed down, let's get back to your original intent and start picking it apart, but you're going to have to give it out one piece at a time.
Title: CAD Setup Routine
Post by: amgirard2003 on February 03, 2004, 01:26:26 PM
Quote from: Daron
Let's take a look at the entity list that you should've gotten using entget. How do you get an item out of the list? How do you put an item into the list? How do you change the properties of an item in the list? When we get this nailed down, let's get back to your original intent and start picking it apart, but you're going to have to give it out one piece at a time.


Getting an item out of the list?
Here's a list of an entity that i selected using entget
((-1 . <Entity name: 4052e608>) (0 . "LINE") (330 . <Entity name: 400a0cf8>) (5 . "2ACD9") (100 . "AcDbEntity") (67 . 0) (410 . "Model") (8 . "C208") (62 . 8 ) (6 . "Continuous") (100 . "AcDbLine") (10 336413.0 4.67845e+006 0.0) (11 336414.0 4.67843e+006 0.0) (210 0.0 0.0 1.0))

You can use either of the following to take this list apart

Car, Cadr, Caddr, cdr and another one is NTH.

Nth: Allows you to extract any item that's in the list
(nth 3 a) this would remove the 3rd item from list a


How do you put an item into the list?

This one here.. i'm a little stumped on it...
can seem to find anything in the help or the book that i have with me..
Some help here would be greatly appreciated

How do you change the properties of an item in the list?

You use the SUBST function to substiture New info for the old info.
(setq a '(40 . 0.50))
(setq b '(40 . 0.25))
I wanna substiture .25 for .50
(setq c (subst '(40 . 0.25) a b))

How is this for a start??
Title: CAD Setup Routine
Post by: daron on February 03, 2004, 01:47:56 PM
Getting an item out of a list?

Your explanation works, but not best practice. Here's an example of something that works better.
Associated list of properties in a text item
Code: [Select]

(-1 . <Entity name: 7da36ab8>)
(0 . "TEXT")
(330 . <Entity name: 7da0ac10>)
(5 . "1D797")
(100 . "AcDbEntity")
(67 . 0)
(410 . "Model")
(8 . "NOTES")
(62 . 2)
(380 . 2)
(100 . "AcDbText")
(10 993.455 36.9634 0.0)
(40 . 9.0)
(1 . "ROOF FRAMING PLAN \"C\"")
(50 . 0.0)
(41 . 1.0)
(51 . 0.0)
(7 . "NOTES03")
(71 . 0)
(72 . 0)
(11 0.0 0.0 0.0)
(210 0.0 0.0 1.0)
(100 . "AcDbText")
(73 . 0)

Instead of using car, cadddddddddr or whatever, let's use ASSOC to associate the dxf value of what we want. If you haven't noticed, I'm helping you learn this by taking the code I gave you here (http://www.theswamp.org/phpBB2/viewtopic.php?p=9922#9922) and picking it apart. Take a look at assoc in the help file to get an understanding of what this should work for and then test different scenario's of it. Also, You'll notice in the subst sub, CONS. Take a look at what's going on there. I brought up car and all that, to make sure you understood those basic concepts. If you want to get just the property of an association dxf value in an array, you can do this: (cdr (assoc 8 entget_var))<- whatever the variable for the entget list is. That is mostly useful when you need to compare if and cond statements against another value. Append will also put a dxf construct into a master list. Be careful with that one, but look into it and experiment with it.
Title: CAD Setup Routine
Post by: amgirard2003 on February 04, 2004, 08:50:57 AM
Alright i took some time and re-read chapters on Managing Entities in my book and Autolisp Manual from Afralisp.
I think i've grabbed this part pretty well... I'm sure there are things that I will be encounter that i will get confused on but as of now i feel comfortable with this topic.. :D
Title: CAD Setup Routine
Post by: daron on February 04, 2004, 09:47:10 AM
So, you understand what ASSOC does and CONS? Okay, let's get into you initial topic. List one thing you'd like to have happen and let's work on it. Wait, before we do, I'd like to impress upon you reusable code and how to use it.
Code: [Select]
(defun alphalist (listas / conv sort)
     (setq conv   (mapcar 'ascii listas)
      sort   (vl-sort conv '<)
     )
     (mapcar 'chr sort)
)

Okay, here is a piece of code that I wrote that will process and sort lists. You can find the description block, here (http://www.theswamp.org/phpBB2/viewtopic.php?t=54). Here is how you use it.
(alphalist '("a" "d" "b" "e" "d"))
That will return a list like this: ("a" "b" "d" "e")
Inside a main program, you could call it like this:
Code: [Select]
(defun c:whatever ()
    (do some stuff here)
    (alphalist '("a" "e" "e" "b" "c"))
    (do some more stuff here)
    (alphalist '("2" "1" "5" "5" "3" "4"))
    (do some more stuff)
    (princ)
)

Now, let's look at the top line of the function:
(defun alphalist (listas / conv sort)
(definefunction name   (required arguments / local variables)
Not all code has to have required arguments or localized variables. You may just want to have a simple piece of code for setting user variables.
Code: [Select]
(defun uvars ()
    (setvar 'osmode 0)
    (setvar 'pdmode 1)
    (setvar 'gridmode 0)
)

No arguments, just call the name of the function where you want those variables changed, like so: (uvars). That may not be the best example, but it's all I could think of. It's early. Back to the alphalist. How do you use the required arguments? Well, take a look at what I've named the single one I've put in: listas. I only use it once, though it could be used as many times as is needed. The first line after the defun is mapcar. Mapcar will take a list and perform a function on each item in that list, right? Listas means nothing to the interpreter. By itself it is a list that is empty. The return value of it is nil. Nil is both nothing and a list element. I think nil means "Nothing In List", but I could be wrong. Anyway, when you call the function like this (alphalist '("a" "b" "d" "d" "c")) you are filling the listas argument (variable) with information. Not all arguments have to be a list, but in this case it does since that is the nature of the function. Each time you call it, you could possibly give it a different list. Is it starting to sink in? Let's take the uvar code above and make it a bit more useful.
Code: [Select]
(defun uvars (omd pdm gdm)
    (setvar 'osmode omd)
    (setvar 'pdmode pdm)
    (setvar 'gridmode gdm)
)

Now, instead of changing all three variables in your code every time you need to, you just call uvars with the correct changes, like so:
Code: [Select]
(defun c:changevars ()
    (collect current variables)
    (do something here)
    (uvars 6175 32 1)
    (do something else here)
    (uvars 512 0 0)
    (reset variables here)
    (princ)
)

You could do that forever, but your main code will be smaller and easier to maintain. So, now that we have that cleared, let's have at it. What's the first thing you'd like to simplify? Are we back to the layer thingy?
Title: CAD Setup Routine
Post by: amgirard2003 on February 04, 2004, 10:12:32 AM
Daron,
I'm taking your previous post in slowly... I've read it a few times and taking a break and then re-reading it...Quite a mouthful, but i won't choke on it.

As far as what is on the table.. the first thing i wanna do is layer thingy that's correct..

I'll give you a quick run down to refresh the memory...
Here's the thing, the city that i live has set standards with all land developpers and consultants to use their layering scheme.. That layering scheme is in numbers (ex. 10, 100, 610, 612, 622 etc.) i know i lot of you have vented over this but the city has control over that.. All drawings that are submitted for subdivision approval have to be in cad format and follow this scheme, if not they will not accept the drawing and will not approve any drawing until they are submitted in this fashion... The company i work for is owned by the city so we follow the same scheme..

What i would like to achieve is this... I know it doesn't sound like the right thing to do but it makes sense to me..
When i enter the Startup Command to load the layers it will load all the layers... when the drawing is completed we will purge the drawing to make the drawing smaller... if at a future time we need to add somethings new to the drawing i would like to be able to re-load the layers but not change the ones that exist already..
I know it sounds dumb... but i am open to other suggestions to improve it..
Title: CAD Setup Routine
Post by: daron on February 04, 2004, 10:50:28 AM
So, the startup routine doesn't sound like the ideal thing to me if you're just going to purge the drawing later. What that's telling me is that whenever any drawing is opened all these standards will be set in place. If you purged the drawing do you really want to "unpurge it" on startup? As far as layername routine goes, I'd take SMadsen's AddLayers (http://www.theswamp.org/phpBB2/viewtopic.php?t=52) lisp and pick it apart until it gives you what you need. I think it's very close to what you might be after. I'd test each line from the inside out until you understand either why you're not getting a return value or why you are. From that you should have a better understanding of the functions he used and how to implement this yourself. I'm pondering a thought that might help you with naming layers like you have to, but give you the ability to know what the layers mean. I'll see if I can bring this thought to fruition. Don't hold your breath, though.
Title: CAD Setup Routine
Post by: amgirard2003 on February 04, 2004, 11:22:39 AM
It seems like i'm confusing you more with this idea..
The idea to input each layer doesn't make sense to me especially when i work with close to 170 layers.. it would seem ridiculous to me to input each of these 1 at a time along with their characteristics..

I want to create one routine (Create Layer)  to create all the layers (this one will be used on the initial startup of a new drawing when the user wants to use this startup routine) and then i want to create another routine (Reset Layers) to reload layers that might have been deleted or purged from the drawing (I will put this routine in a pulldown and it will not be part of the initial startup).

Does that clear it a little bit?
Title: CAD Setup Routine
Post by: daron on February 04, 2004, 01:42:12 PM
Yup. Still, pick Stig's routine apart. It'll help you a lot. At the same time, I'm thinking about having you use multi-dimensional arrays, but those are a little too advanced for your level, I think. Who knows, maybe we'll need to. Just a primer, think of arrays like this:
A variable contains all its information as if it were one container, like a barrel. Not too easy to keep things organized in a barrel is it? Arrays are like those filing trays you probably have sitting in your office. In-box, Out-box, homework, etc., etc. So, to display it a little:
Title: CAD Setup Routine
Post by: amgirard2003 on February 04, 2004, 02:26:25 PM
I kind of understand... It sounds like a round robin tournament schedule...
If i understand it right i like that idea...

I've been playing with smaden routine..... and still dissecting it line by line to understand what is goin on...

Is using arrays diving into Visual Lisp?
Title: CAD Setup Routine
Post by: daron on February 04, 2004, 02:43:25 PM
Yup. Before we dive into ActiveX VLisp, I'd like to see your level (feel) of programming in general get higher.
Title: CAD Setup Routine
Post by: amgirard2003 on February 04, 2004, 02:52:53 PM
Quote from: Daron
Yup. Before we dive into ActiveX VLisp, I'd like to see your level (feel) of programming in general get higher.


Oh that level right now i would say is about 2 out of 10
So i gots a long way to go..

Since you have a better knowledge of what can be done with Autolisp and it's practical uses.. Do you have any good ideas for me to work on, involving what i've learned so far?
Title: CAD Setup Routine
Post by: daron on February 04, 2004, 02:58:34 PM
How are you coming at understanding Stig's function? As far as gaining proficiency at coding, take some tasks you perform repetitively and see if you can't make them simpler. That's how I started. I got tired of the slow, mundane repetition and started asking questions about how to improve it through lisp.

2 out of 10. That's far better than 0 out of 10. I think you've come a long way.
Title: CAD Setup Routine
Post by: amgirard2003 on February 04, 2004, 03:16:25 PM
Got an idea that you can help me on..
I do this all day long and it does get tedious after awhile...
I do a lot of pedit, confirm to make it a pline, and then join the lines together.. it would be nice to turn that into one command..

How does that sound?
Title: CAD Setup Routine
Post by: Keith™ on February 04, 2004, 03:21:03 PM
That sounds like a good idea.....

Post a bit of code and we will tell you why it won't work ... :lol:
Title: CAD Setup Routine
Post by: daron on February 04, 2004, 04:09:19 PM
All the things I showed earlier can be used to do what you ask. Just not the same way.
ssget
entmod
entupd
subst
How's that for a start. I don't think you should have to get into dxf lists on that one, but I could be wrong. I haven't thought about that one in a long time.
Title: CAD Setup Routine
Post by: daron on February 05, 2004, 01:47:14 AM
One thing you might do is write down what it takes to complete one pedit, normally. I.E. pe "" select object "" "y" "" "" "" "". That sort of thing. At the same time, I just wrote a little something in the TEACH ME (http://theswamp.org/phpBB2/viewtopic.php?t=780) forum you should take a look at pertaining to array's in standard lisp.
Title: CAD Setup Routine
Post by: amgirard2003 on February 05, 2004, 08:37:13 AM
Mornin,

Well i wrote some things down for this little project here..
A little confused on how to put it all together but i'll get the pseudo code
down and let you see if i'm on the right side of the road with this one.

1. Select entities that you want to convert to a polyline and want to join together.
2. convert entitie to a polyline
3. update entitie
4. repeat through a loop until all entities selected have been updated
5. once updated, join the connecting entities together.
Title: CAD Setup Routine
Post by: SMadsen on February 05, 2004, 08:51:05 AM
*me gets the creeps to see the term arrays used in LISP* *shudder*


Hey, I didn't write ^that .. who edited my post? :)

Sorry Stig. I was wondering where that went. I meant to hit quote, not edit. Daron
Title: CAD Setup Routine
Post by: amgirard2003 on February 05, 2004, 08:55:44 AM
Code: [Select]

(defun c:plc ()
  (setq entname (entget (ssname (ssget) 0)))
  (setq entnum (sslength entname))
  (setq count 0)
)  


Taking it one step at a time..

Question: How do I work a Prompt in to this code to prompt the user to "Select objects to convert"  I don't know how to integrate it and i was playing with it but it wasn't working the way i wanted it to....
Title: CAD Setup Routine
Post by: daron on February 05, 2004, 09:12:28 AM
Quote from: SMadsen
*me gets the creeps to see the term arrays used in LISP* *shudder*


I'm sure you would, but the first time I used the word, I said I was using the word loosly. Here's something I didn't mention in my teach me tutorial: picksets. What is a pickset? It's not a list, so it can't be looped through with foreach. It's not an array, but it sort of is, because it is a multitude of entities within a single variable. Come to think of it, it is an array, just I don't think it can become multi-dimensional. What's a pickset?
Title: CAD Setup Routine
Post by: daron on February 05, 2004, 09:24:41 AM
ssget prompts your user on its own, but you can issue a (princ "We're converting lines to polylines. Which one's would you like I should beat into submission?: ") before the ssget. Now, an issue with your code. You are allowing for multiple selection by issuing an ssget, but limiting it to the first item that autocad decides upon. An entget (entity list) is not a selection set, so sslength will not work on it. It seems that you want to loop through this which is fine, but I think you need to understand the way autocad works with pedit a bit more. When you type pedit, it prompts you with this:
PEDIT Select polyline or [Multiple]:
Let's ignore the Multiple for a moment. It's not what you might think. Issue the pedit command and tell me how many items you can select, then tell me which of these only and I mean only allows that many items to be selected: entsel or ssget?
Title: CAD Setup Routine
Post by: amgirard2003 on February 05, 2004, 09:33:22 AM
When I issue that Pedit command and ignoring the multiple it will allow only one selection so i should use entsel.
Title: CAD Setup Routine
Post by: daron on February 05, 2004, 09:44:08 AM
Of course when you get through the initial selection and type join you then are able to select multiple objects right? When you do, you will notice that they are all joined. Let's look at the other side: [Multiple]. Type pedit again and select M for multiple. Select a few items and make them polylines and exit out. What's happening?
Title: CAD Setup Routine
Post by: amgirard2003 on February 05, 2004, 09:49:04 AM
When i pick multiple lines when issuing the "MULTIPLE" after making my selection, it prompts you a verification (Y/N) if you want to convert them to a polyline.
Title: CAD Setup Routine
Post by: daron on February 05, 2004, 10:00:06 AM
But it does not join them. It does serve a purpose in making everything a polyline, though. At any rate, either way will work. From your code, I assume you want to be able to select all lines and arcs at once and just have them joined, so, ssget will be fine. Let's take your code again.
Code: [Select]

(setq ss (ssget))
(setq ssl (sslength ss))
(setq cnt 0)

See if you can figure out what you need to do from here. Notice I have yet to use ssname or entget. Show how you're going to use them by writing code. No pseudo-code. You've given enough of that, plus I'm awful when it comes to that stuff. If I have an idea, I start hacking away at code until I get it.
Title: CAD Setup Routine
Post by: amgirard2003 on February 05, 2004, 10:21:06 AM
Code: [Select]


(setq ss (ssget))
(setq ssl (sslength ss))
(setq cnt 0)

(repeat ssl
  (setq ename (ssname ss cnt)); set the first entity to ename
  (setq elist (entget ename)) ; get the name of that first entity.
   


This is where i'm at so far... running into a stumbling block now..
Title: CAD Setup Routine
Post by: Keith™ on February 05, 2004, 10:28:45 AM
Let me make a little comment here ...

How are you planning on joining the polylines once created? The answer may make a difference in the way the selection set is handled.
Title: CAD Setup Routine
Post by: SMadsen on February 05, 2004, 10:34:02 AM
Daron, arrays are - at least historically - indexed by offsetting addresses. In order to index that way, you need contiguous spaces in memory and statically sized data types.
Lists are like linked lists. They do not require contiguous memory and can be dynamically allocated without flushing the entire structure.

I know you used the term loosely and for the purpose of understanding. Just be aware that the term 'array' do not quite cover all of the features of a list. For example, using the term 'multidimensional array' for a nested list can give the impression that each element has to hold the same number of levels - which is not correct.
Title: CAD Setup Routine
Post by: amgirard2003 on February 05, 2004, 11:12:56 AM
I would like it to work like this
pick the objects first convert them to plines and the join them individually..

a little frustrated....  :x
Title: CAD Setup Routine
Post by: daron on February 05, 2004, 11:17:34 AM
True, but in the case with layers, we'd want to do some math to make sure all lists in the main list have the same elements, right? As I ponder your statement a bit, it seems that lists and nested lists are more flexible than arrays, but can also have more issues, in that if you have a list of 5 layer name and a list that only contain 4 colors and the 3rd color is what is missing, you'd end up with (5 3 2 1 nil) not (5 3 nil 2 1) appended to their respective layers, right?

Thanks for keeping me in check though. Any time I'm explaining something and it's not quite right, feel free to correct me. I may understand how many functions work, but my explanation does tend to get a little skewed and opinionated.
Title: CAD Setup Routine
Post by: daron on February 05, 2004, 11:19:01 AM
Quote from: amgirard2003
I would like it to work like this
pick the objects first convert them to plines and the join them individually..

a little frustrated....  :x


That seems a little backward of the way the command works normally.
I was thinking you wanted to select all the lines at once and have them join automatically?
Title: CAD Setup Routine
Post by: amgirard2003 on February 05, 2004, 11:44:52 AM
i can't seem to explain exactly what i want to do..

I'm just frustrated that i can't seem to put 1+1 together to = 2.. I feel like i'm getting 100 as my answer...
I just can grip the logic when you all put your code together..
What i mean by that is when you get a problem...
when you start to dissect that problem and start writting code to solve the problem,  you all seem to have a structure to your code... (this goes here and that there, oh i should put this here as well)  it's that what i'm not getting..I'm not getting how you all put your code together... I'm not fully understanding why you would use this over that or do it this way instead of that way...

I've learned a lot about all the function and how they work individually, but when trying to put them together to function as a group.. i just throw my arm's in the air and just wanna yell!!!..
And that's when i start to get frustrated...  :x

I just want to say you've all done a great job and teaching me everything so far... I just thought i would bring this up to maybe direct your thougths to this point..
I guess i should post a routine and understand your thinking behind it..
here's a simple one... i understand how it works... but mentally it would have taken me days to even figure where to start with the code..
What would be your thoughts when doing this routine?


Code: [Select]

(defun C:COPYROT (/ SS1 P1 P2 RT)
  (prompt "\nCopy and Rotation combined.")
  (setq SS1 (ssget)
RT  0.0
  )
  (if SS1
    (progn
      (setq P1 (getpoint "\nBase point for copy: "))
      (if P1
(while (setq P2 (getpoint P1 "\nCopy point: "))
 (setq TMP (getangle P2
     (strcat "\nRotation angle <0.0>: ")
   )
 )
 (if TMP
   (setq RT TMP)
   (setq RT 0.0)
 )
 (command "_COPY"
SS1
""
P1
P1
"_MOVE"
SS1
""
P1
P2
"_ROTATE"
SS1
""
P2
(angtos RT)
  ) ;;end Command
  (setq P1 P2)
) ;;end WHILE P2
      ) ;;end If P1
    ) ;;end PROGN
  ) ;; end IF SS1
)


If anyone wants to jump off this sinking ship feel free to do so.... :(
Title: CAD Setup Routine
Post by: daron on February 05, 2004, 11:55:36 AM
Don't know. As far as jumping ship on you? What kind of people would we be if we did that? Nobody jumped ship on me or anybody else, when we were going through the same frustrations. Don't worry, as long as you don't jump ship, I'm pretty sure nobody else will either. Keep at it. One day, it'll all just click and you'll wonder why it took so long to understand it. Let's not get sidetracked. That little tutorial I did on the similarities between lists and arrays came from reading about arrays while pondering the way you want to set your standards up for layer creation. If you want we can get back to that. I think I have an idea involving that.
Title: CAD Setup Routine
Post by: amgirard2003 on February 05, 2004, 01:05:41 PM
I should give you a run down as to what i have a clear grasp of..

Variables:

Local Variable: are variables defined after the /, are available to that function only and reset themselves when the routine exits.
ex: (Defun c: cp ( / on off)  on and off are local variables

Global Variable: are variables that are not defined as either arguements before the / or within the routine itself, being global they are available to all routine and do not clear themselves when the routine exits..
ex: (defun c: cp ( on off /) ; "on, off" are recognized as argurments
      (setq an "Hello") ; "an" is a global variable

(getpoint): used to specify a point on the screen and return  X, Y corrdinates of the selected point.
(setq a (getpoint "Please select Point"))

(getangle): get an angle by selecting 2 points or input from the keyboard
(setq a (getangle "Enter Angle" ))

(getkword): used with Initget to retrieve keyword selections.
(initget 1 "L E")
(setq a (getkword "(L)ength or (E)nd"))

(getvar): gets an AutoCad variable.
(setq a (getvar "cmdecho"))

(getdist): requests input from the user either through clicking between 2 points or keyboard.
(ex. (setq a (getdist "Enter Length "))

(getreal): requests input as real number.
(ex. (setq a (getreal "Enter a Number" ))

Real Number: a number that includes a decimal point


(defun): to define a custom function.. if (defun c:new) then it will act like an AutoCad command.

That's a quick run down of what i've encountered so far and feel i've got a good handle on, along with everything else you have shown me in this thread as well..
Title: CAD Setup Routine
Post by: daron on February 05, 2004, 01:26:53 PM
Put together a list of all layers, on-off, frozen-thawed, locked-unlocked, layer colors, linetypes, lineweights, plottability. Do you use paperspace?
Title: CAD Setup Routine
Post by: amgirard2003 on February 05, 2004, 01:42:33 PM
Yupe.... that's the real way to plot in Autocad... big pet peeve of mine is consultants that either draw and border everything in model space or they will have complete drawing drawn in paperspace... blows my mind sometimes..

I have a list right right next to me..
Title: CAD Setup Routine
Post by: daron on February 05, 2004, 01:54:20 PM
Well, start typing.
Title: CAD Setup Routine
Post by: amgirard2003 on February 05, 2004, 01:59:11 PM
Do you want the full list or partial list?
I have close to 200 here..
Title: CAD Setup Routine
Post by: daron on February 05, 2004, 02:02:56 PM
Why don't you give me 10 and I'll see what I can do with them.
Title: CAD Setup Routine
Post by: amgirard2003 on February 05, 2004, 02:08:32 PM
layer, color , linetype

610 , magenta, continuous
612 , magenta, hidden
622 , yellow , hidden
626 , green, continuous
410 , 8 , conitnuous
198 , 7 , continuous
102 , cyan , continous
49 , 50, continous
60 , 70 , continous
64, 7, continous

all of these layers are ON, Thawed, Unlocked, lineweight is default (we use ctb files when plotting) and all plot..
Title: CAD Setup Routine
Post by: amgirard2003 on February 05, 2004, 02:17:46 PM
my head is sore trying to figure out this pedit thingy...
don't know where to begin...
Title: CAD Setup Routine
Post by: daron on February 05, 2004, 04:17:17 PM
Keep the pedit thing in the back of your mind, but focus on this a moment:
Code: [Select]

;;;creates a nested list of layernames, colors and linetypes
;;;return value: three lists of multiple items
(defun multi-list-layers ()
     (list
 (list "610" "612" "622" "626" "410" "198" "102" "49" "60" "64")
 ;;layername list
 (list 6 6 2 3 8 7 4 50 70 7)
 ;;layer color list
 (list "continuous" "hidden"  "hidden"
"continuous" "conitnuous"  "continuous"
"continous" "continous"  "continous"
"continous"
      )
 ;;layer linetypes list
     )
)
;;;creates a nested list of layers with properties in each container
;;;return value: ex. ("610" 6 "continuous)
(defun multi-layer-list ()
     (list
 (list "610" 6 "continuous") ;name color linetype
 (list "612" 6 "hidden")
 (list "622" 2 "hidden")
 (list "626" 3 "continuous")
 (list "410" 8 "continuous")
 (list "198" 7 "continuous")
 (list "102" 4 "continuous")
 (list "49" 50 "continuous")
 (list "60" 70 "continuous")
 (list "64" 7 "continuous")
     )
)

There's two ways here to set up a list. The first one creates a list for each type of property i.e. a list of layer names, a list of colors and a list of linetypes. You will only ever have three lists in that list, but on the whole it can get confusing if you need to update anything or add to it. The second function will create a list of lists each containing three properties. This way is much easier to digest, and update. I'm showing both because the first way was the idea in my head. So, it in a sense is my pseudo-code. You will probably agree that the second one makes more sense, as do I. Both will work, though. What do you think as this being a way to set up your layers? Of course, it's only a set of lists at this point and won't do anything but return a set of lists. It's a work in progress. Take it, test it, add the rest of your layers to it. Tell me what you think. The next step is either creating a function to process each list to creating each layer and its respective property or taking one of the many layer creation tools that are on this site and modifying it to suit.
Title: CAD Setup Routine
Post by: amgirard2003 on February 09, 2004, 07:33:35 AM
Thanks Daron for your help..
I'll create a list with all the layers that i have and i will let you know when i'm done..
I'm back with a clearer mind and ready to learn some new things..
Title: CAD Setup Routine
Post by: CAB on February 09, 2004, 08:38:40 AM
Quote from: amgirard2003
I've learned a lot about all the function and how they work individually, but when trying to put them together to function as a group.. i just throw my arm's in the air and just wanna yell!!!..
And that's when i start to get frustrated...


You have learned several words (functions) very well and you have a
vague idea of the meaning of quite a few more. But you feel frustrated
you can't speak the language fluently. Well, you have come a long
way in a short time (thanks to Daron and others). I can only speak for
myself but it appears you are close to the point where you can put short
phrases together and soon after that sentences. And only then can you carry
on a conversation. After one year I am starting to feel comfortable with lisp
and in looking back at previous conversations (routines) I misused some of
the words, poor grammar etc, but I was able to converse. Keep it up and the folks
here will help you along your journey. Mostly gently, sometime not, but always
with good intention. :)

CAB
Title: CAD Setup Routine
Post by: SMadsen on February 09, 2004, 08:44:34 AM
To make it easier on yourself when creating the layer list, you can decide to make it possible to omit some of the information. For example, if omitting color number and/or linetype name, you can assign default values when creating the layers.

The syntax for each layer item could be
(layername [color [ltype]]),
where layername is obligatory, while color and linetype can be omitted. Omitting color cannot be done without also omitting linetype.

Anyway, some code should make this clearer:
Code: [Select]
(defun multi-layer-list ()
  ;; format: name color linetype
  (list
    '("610" 6)
    '("612" 6 "hidden")
    '("622" 2 "hidden")
    '("626" 3)
    '("410" 8)
    '("198")
    '("102" "hidden")
    '("49" 50)
    '("60" 70)
    '("64"))
)

(defun makeLayers (/ failed layerlist name color ltype)
  (setq failed 0)
  (cond
    ;; get pre-formatted list of layers
    ((setq layerlist (multi-layer-list))
     ;; Run through each item in layerlist, assign
     ;; name, color and linetype. If any item is
     ;; missing, we'll deal with it at the time of
     ;; layer creation
     (foreach layer layerlist
       (setq name  (car layer)
             color (cadr layer)
             ltype (caddr layer)
       )
       ;; Do the actual creation of layers. If color and/or
       ;; linetype is missing, then assign some default values.
       (if (not (entmake
             (list '(0 . "LAYER")
                   '(100 . "AcDbSymbolTableRecord")
                   '(100 . "AcDbLayerTableRecord")
                   ;; Insert layer name
                   (cons 2 name)
                   ;; Insert color by layerlist or default of 7 if missing
                   (cond ((= (type color) 'INT) (cons 62 color))
                         ((cons 62 7))
                   )
                   ;; Insert ltype if found in linetype table.
                   ;; If not found or missing in layerlist then
                   ;; insert default linetype, i.e. "Continuous"
                   (cond
                     ((and (= (type ltype) 'STR) (tblsearch "LTYPE" ltype))
                     (cons 6 ltype))
                     ((cons 6 "Continuous"))
                   )
                   '(70 . 0)
             )
           )
         )
         ;; If layer creation failed then increment counter
         (setq failed (1+ failed))
       )
     )
     ;; If some layer creations failed then report it. Notice that
     ;; failing to create a layer can also be caused by the fact that
     ;; the layer already exists
     (if (not (zerop failed))
       (princ (strcat "\nFailed to make " (itoa failed) " layers"))
     )
    )
  )
  (princ)
)
Title: CAD Setup Routine
Post by: daron on February 09, 2004, 09:43:49 AM
Andre' I couldn't imagine a better, faster way of doing what Stig just did. Thanks, Stig. The challenge, Andre' is to take out all the comments, so you have just code and step through each line. Better yet, so you can step through each line, I've altered Stig's makelayer function from using foreach and made it repeat. The challenge here is to step through the repeat version and see what makes it tick, then go back to the foreach version and try to understand it. The best way to understand a foreach function that I've found is, under debug, select animate and just watch what is going to happen as the vlide steps through the function. Do this only when you have some spare time. It can be a slow arduous process. Don't do it on more than 3 or 4 layers. Here's the repeat version:
Code: [Select]
(defun makeLayers (/ failed layerlist name color ltype)
  (setq failed 0
cnt 0)
  (cond
    ((setq layerlist (multi-layer-list))
     (repeat (length layerlist)
       (setq name  (car (nth cnt layerlist))
             color (cadr (nth cnt layerlist))
             ltype (caddr (nth cnt layerlist))
       )
       (if (not (entmake
             (list '(0 . "LAYER")
                   '(100 . "AcDbSymbolTableRecord")
                   '(100 . "AcDbLayerTableRecord")
                   (cons 2 name)
                   (cond ((= (type color) 'INT) (cons 62 color))
                         ((cons 62 7))
                   )
                   (cond
                     ((and (= (type ltype) 'STR) (tblsearch "LTYPE" ltype))
                     (cons 6 ltype))
                     ((cons 6 "Continuous"))
                   )
                   '(70 . 0)
             )
           )
         )
         (setq failed (1+ failed))
       )
 (setq cnt (1+ cnt))
     )
     (if (not (zerop failed))
       (princ (strcat "\nFailed to make " (itoa failed) " layers"))
     )
    )
  )
  (princ)
)
Title: CAD Setup Routine
Post by: amgirard2003 on February 09, 2004, 10:11:31 AM
Quote from: CAB

You have learned several words (functions) very well and you have a
vague idea of the meaning of quite a few more. But you feel frustrated
you can't speak the language fluently. Well, you have come a long
way in a short time (thanks to Daron and others). I can only speak for
myself but it appears you are close to the point where you can put short
phrases together and soon after that sentences. And only then can you carry
on a conversation. After one year I am starting to feel comfortable with lisp
and in looking back at previous conversations (routines) I misused some of
the words, poor grammar etc, but I was able to converse. Keep it up and the folks
here will help you along your journey. Mostly gently, sometime not, but always
with good intention. :)

CAB


CAB- you hit the nail on head.... that is exactly how i feel.... i understand how the functions work (WORDS) but putting the (WORDS) together to make a clear sentence (ROUTINE) is where i get lost...

I know it will take time before i'll be able to make comprehendible sentences, but i will be patient and take my time to learn all that i can.
Title: CAD Setup Routine
Post by: amgirard2003 on February 09, 2004, 11:54:21 AM
I've been playing around with the 2 routines and i feel i understand them pretty well... I'm still tryin to understand what you guys think about when you're putting the routine together...
Overall i understand both pretty well... I can see what they are doing and what all the functions are doing as well.. :D

That would take care of both the creations and re-loading of the layers.
Title: CAD Setup Routine
Post by: daron on February 09, 2004, 12:06:17 PM
Here's something I didn't write. It was here, when I got here. I don't even like to look at it, but it should help you with the pljoin function.
Code: [Select]
(defun c:plj (/ ss i en et osm snm) ; STAND-ALONE FUNCTION.
     (setq osm (getvar "OSMODE")
  snm (getvar "SNAPMODE")
     ) ; SAVE MODES.
     (setvar "CMDECHO" 0)
     (setvar "OSMODE" 0)
     (setvar "SNAPMODE" 0)
     (prompt
 "  PLineJoin... Select the Lines, Arcs, and Plines to Join:"
     ) ;_ end of prompt
     (if (setq ss (ssget))
 (progn

 ; MUST REMOVE CLOSED, FITCURVED, & SPLINED PLINES FROM SELECTION SET.
      (prompt "Initial scan")
      (setq i (1- (sslength ss)))
      (while (>= i 0)
   (setq et  (cdr (assoc 0
 (entget (setq en (ssname ss i)))
  ) ;_ end of assoc
     ) ;_ end of cdr
   ) ;_ end of setq
   (cond ((or (= et "LINE") (= et "ARC")))
 ((= et "LWPOLYLINE")
  (if (> (cdr (assoc 70 (entget en))) 0)
 ; IF>0, PLINE FLAGS SET.
(ssdel en ss)
  ) ;_ end of if
 ) ; END IF & "POLYLINE".
 (t (ssdel en ss)) ; END T
   ) ; END COND
   (prompt ".")
   (setq i (1- i))
      ) ; END WHILE
 ; END MUST REMOVE.

      (setq i (1- (sslength ss)))
      (while (>= i 0)
   (setq et  (cdr (assoc 0
 (entget (setq en (ssname ss i)))
  ) ;_ end of assoc
     ) ;_ end of cdr
   ) ;_ end of setq
   (cond ((= et "LWPOLYLINE")
  (command ".PEDIT" en "J" ss "" "X")
 )
 ((= et "LINE")
  (command ".PEDIT" en "Y" "J" ss "" "x")
 )
 ((= et "ARC")
  (command ".PEDIT" en "Y" "J" ss "" "x")
 )
   ) ; END COND.
   (setq i (1- i))
   (prompt ".")
      ) ;_ end of while
 ) ;_ end of progn
     ) ; END OF WHILE i<lth, PROGN, IF ss
     (setvar "OSMODE" osm)
     (setvar "SNAPMODE" snm) ; RESTORE MODES.
     (setvar "CMDECHO" 1)
     (setq i "Done joining.")
) ; END FUNC.


Back to the previous two functions. Stig used, in the foreach, (car layer)... I used in the repeat, (car (nth cnt layername)... Why?
Title: CAD Setup Routine
Post by: amgirard2003 on February 09, 2004, 12:53:39 PM
Quote from: Daron
Back to the previous two functions. Stig used, in the foreach, (car layer)... I used in the repeat, (car (nth cnt layerlist)... Why?


In the repeat function you used the (car (nth cnt layerlist) because you wanted to return of the first element of the current list it is looking at..

EX:Line 1 (list "610" 6 "continuous")  
     Line 2 (list "612" 6 "hidden")
     Line 3 (list "622" 2 "hidden")
     Line 4 (list "626" 3 "continuous")

car: would return the layer name
nth: is the line of the list (cnt = line 1)

I couldn't figure out how to say it right but i hope you'll get what i'm tryin to say.
Title: CAD Setup Routine
Post by: daron on February 09, 2004, 01:02:02 PM
Okay, so why doesn't Stig have to do that in the foreach? What's so special about it? What I'm trying to get to, is to see if you know what you have to do to be able to take a line in a foreach code and inspect it. What's the next thing you want to do, after layers?
Title: CAD Setup Routine
Post by: amgirard2003 on February 09, 2004, 01:16:09 PM
In stig's routine FOREACH works exactly like the nth function..it's like built into the foreach function.
You specify what part of the list you want to return and it will go through
each line of the list and return that part.
Title: CAD Setup Routine
Post by: daron on February 09, 2004, 01:41:12 PM
Here we're working with nested lists. Foreach steps through each element of the outermost list, and works on the contents of that element. Typing (car (nth cnt layerlist)) is exactly what the foreach functions is doing, except you don't have to tell foreach how to get to the next element. So, some pseudo-code: foreach list in variable layerlist, save each item in the list to its own variable i.e. (car, cadr, caddr) and process these items as needed before looking at the next list in the main list and continue until every list in the main list has been stepped through.

Sorry if I keep going over the same things, but I want this to click for you. I used repeat for 4 years before I figured out foreach. It wasn't until I asked Mark about it and realized that I was missing one crucial element in my code, to making foreach work. That element was a list. I knew it processed multiple items, but I failed to realize that selection sets and lists are not the same. Anyway, where are we at? What's next?
Title: CAD Setup Routine
Post by: amgirard2003 on February 09, 2004, 02:04:24 PM
Quote from: Daron

Sorry if I keep going over the same things, but I want this to click for you. I used repeat for 4 years before I figured out foreach. It wasn't until I asked Mark about it and realized that I was missing one crucial element in my code, to making foreach work. That element was a list. I knew it processed multiple items, but I failed to realize that selection sets and lists are not the same. Anyway, where are we at? What's next?


No problem... I appreciated the extra info that i'm not seeing and when you explain it, it makes a lot more sense... It's clicking really well today..
As we progress through this it will help me out with writting (as CAB would say) sentences...

You mentioned somethin that caught my eye...
You said selection sets and list are not the same?  When you create a selection set aren't you not creating a list of items within that selection?


What about making slides??
Title: CAD Setup Routine
Post by: SMadsen on February 09, 2004, 02:38:27 PM
Andre, lists and selection sets are as different as integers and strings. They are simply different data types that require different handling.
Title: CAD Setup Routine
Post by: daron on February 10, 2004, 09:24:50 AM
That's not to say that you can't convert a selection set into a list of selections. We do it all the time. Mark made a really cool recursive converter that I modified to keep each selection as a selection instead of converting each selection to a vba-object.

Slides? I don't assume you're talking about plastic/metal ramps for playing on. What do you need slides for? What do you want to do with them?
Title: CAD Setup Routine
Post by: amgirard2003 on February 10, 2004, 10:21:43 AM
Let's forget about the slide idea and stay with the autolisp
how about my idea with the scale..

First determine if the template is Metric or Imperial..
Prompt the user to enter a scale and set the drawing depending on the scale that was entered.
Title: CAD Setup Routine
Post by: daron on February 10, 2004, 10:30:09 AM
Any ideas how you might determine the type of template? Example: Is there any words in the templates you might look for? That's not the most stable idea. Have a look at dimension variables. If you have express tools, there is a system variable editor that shows most, if not all of the variables, their values and description. Look at any of them starting with dim. I believe there would be some that will tell you what you're looking for. Let me know what you find and we'll start coding from there.

 What would the different scales be that a user, in your company might enter? Why would you change the scale of the drawing? Wouldn't you just draw at 1:1 and set the printer to print at what scale you need, unless of course, you're doing land development?
Title: CAD Setup Routine
Post by: amgirard2003 on February 10, 2004, 10:50:09 AM
Well not necessarily change the drawing scale... more of less set the drawing up for plotting at the scale that was entered.

Something like this..

user enters a scale of 1:500 metric..
I would like to create a Viewport function that would reflect the scale that is entered.
If any kind of details entered would be scaled to reflect that scale as well..

It's hard to write down the idea that's in my head.. so you can get a clear idea of what i'm tryin to get too..
Title: CAD Setup Routine
Post by: amgirard2003 on February 10, 2004, 11:15:03 AM
I'm still going over the layer routine that you and Stig posted to make sure it fully sinks in and to see things that might not be standing out to me that i should be looking for.
Title: CAD Setup Routine
Post by: daron on February 10, 2004, 11:50:07 AM
That's good to hear. I was going to take a look at it again and see if there isn't some way of processing the inner lists differently, too. I'll let you know what I come up with. As far as the plot scale thing goes, I'll have to ponder that one a bit, but I might have some page setup routines that might be what you're looking for.
Title: CAD Setup Routine
Post by: amgirard2003 on February 11, 2004, 08:13:26 AM
Sorry Guys, but i gotta jet for the rest of the week...
Boss just dropped off a huge project that i have to work on..
I'll be back when i'm done..
Title: CAD Setup Routine
Post by: amgirard2003 on February 24, 2004, 08:05:54 AM
Hey Guys,
I'm finally back from the garbage I was working on...
I'm not gonna start to vent on that...

I was doin some thinking while i was away and thought after all that i've gone through so far that i've dived in to deep into this project..
I wanna take it slower and learn more of coding and how to put it together..
I wanna work on any examples but easier ones to comprehend would work better for now..

Let me know what you all think?
Title: CAD Setup Routine
Post by: daron on February 24, 2004, 08:35:06 AM
Well, I'm going to be out Wednesday-Friday, so I won't be able to help much, but put up what you'd like to work on and I'm sure there will be others to help out.
Title: CAD Setup Routine
Post by: amgirard2003 on February 24, 2004, 09:23:09 AM
Well i don't have any ideas as of yet but looking for some examples that you felt really helped you understand writting and putting code together.