Wow! This is way more than I would have imagined it would be to such (seemly) simple process.
Even though I have trouble creating lisp from scratch I can read them and understand what they can do. Most of the time. This one looks like it will work Lee. I appreciate your time. I will try this out as soon as I get to work in the morning. I could VPN but I'm too damn tired at the moment.
I really look forward to learning how to get to this point in writing lisp myself.
Thanks again Lee. BIGAL what you said makes perfect since to me after reading what Lee Mac added.
BTW how do you put the code in a neat frame like that? I do understand HTML but I have not gotten this complex with it.
Thanks for your message, just wrap your code in [ code] [/ code] tags (without the spaces), to put it in the frame. Or, alternatively, select all your code and click on the # button on the post text editor.
It could probably be made simpler by using a default text file (iradicating the need for the separate (defun selfile) program. Also, I have added an error handler which makes it look more complicated than it is.
In writing it, I wasn't sure if you were after a LISP to insert a single block numerous times, or lots of different blocks at lots of different coordinates - if it was the latter, obviously the LISP will need to be altered somehwhat.
Also, one more thing, I have left the filepath for the block blank, but remember (and you probably know this already) to use a double backslash \\ to indicate the single backslash \.
Yeah I noticed that. I'm glad you added that because now I know how the syntax looks.
The former is correct. I just wanted to be able to place one tree block on each coordinate so we can show which trees would need to be cut down. For instance a block of a tree with an X through it to denote demolition.
Actually I did not know this. Thanks for the heads-up.
Does the format of the file with the coordinates matter? From what I can tell it will except the file format of the coordinates as the command expects them to see them. (i.e. x,y or y,x) Does this read the entire set of coordinates all at once and store them in memory or does it read them one line at a time? If the latter how does it know to move onto the next line after it places the block?
If you don't mind would you comment on each line of code starting at the (selfile) so that I can wrap my head around it and turn this into a greater learning process? Some of it I understand but a few lines I do not because I am not familiar with some of the operators and arguments.
Ok, first I will admit - I have never used this method for inserting a block into a drawing and haven't actually tested my posted LISP yet either.
But I read something about the read-line command earlier that day and thought I'd try and use it.
But I'll help as much as I can.
The read-line syntax will read the file line by line until it returns nil - as I say I have not tried to use it before, so I am not sure if I have even used it correctly. But I would say that the co-ordinates need to be in the form that the command would expect them.
[code](defun c:ITREE (/ file1) (defun *error* (msg) ; define error handler (setvar "cmdecho" 1) ; if an error set the command echo back to 1 (if (= msg "") ; if the msg argument with the error is "" (princ "\nFunction Complete.") ; then print Function Complete (princ "\nError or Esc Pressed.") ; otherwise print Error... ) ;_ end if ) ;_ end defun (selfile) ; invoke selfile (setvar "cmdecho" 0) ; turn off the command echo (for when we use the insert) (setq file1 (open file "r")) ; open the selected file for reading (while ; as it says on the tin (/= (read-line file1) nil) ; up until the readline cannot read any more lines (command "-insert" ; invoke insert "C:\\" ;