Author Topic: trying to write my first lisp and i need a bit of help  (Read 23556 times)

0 Members and 1 Guest are viewing this topic.

daron

  • Guest
trying to write my first lisp and i need a bit of help
« Reply #75 on: July 28, 2005, 01:28:05 PM »
I'm sure that's more entertaining. She's a fun speaker.

ELOQUINTET

  • Guest
trying to write my first lisp and i need a bit of help
« Reply #76 on: July 28, 2005, 03:29:52 PM »
sorry bout that daron i was listening to lynn then went out for lunch. let's see, that last part is to move the text 2. 'ill read through the code some more

ELOQUINTET

  • Guest
trying to write my first lisp and i need a bit of help
« Reply #77 on: July 28, 2005, 03:47:21 PM »
daron i know what you are trying to do being that you are an experienced programmer. you are trying to write the programmer for all situations. the problem on my end is that my boss keeps checking in on me and asking me how it's going. i told her that we are doing some further development of the routine. she says while that is a good thought she wants me to keep it simple so i can easily interpret what is going on. then as i progress the routine can be further developed. she wants me to just write a routine that does what i described in my psuedo code only for horizontal dimensions then be able to know exactly what is happening. in other words can we just extract the code11 from the dimension then place the text 3.5 below that point. sorry but she is about to give me a drawing to do so i will have to take a break from writing anything after today. i will continue to read and come up with a list of questions as i go.

daron

  • Guest
trying to write my first lisp and i need a bit of help
« Reply #78 on: July 28, 2005, 03:51:41 PM »
Not to move the text any, yet. I think you might be on to something though. Consider what code42 is and what (/ dimassoc42 2.0) means. It's just math. Consider that this (/ dimassoc10 2.0) won't work and explain why. You'll find / under Operators in the Alisp Reference. You'll also slap yourself if you didn't realize that it is telling the computer to divide one element from the other. Don't confuse it with (defun (/ errata) in the first line of this routine. They aren't the same. Confusing enough? Well, I'm going home. Until tomorrow.

If you need any extra work, look up subst (substitute), entmod (ENTity MODify), entupd (ENTity UPDate) and cons (CONStruct). Fun fun. Oh, explain all your findings of each. This way I know where you stand.

ELOQUINTET

  • Guest
trying to write my first lisp and i need a bit of help
« Reply #79 on: July 29, 2005, 09:21:22 AM »
daron i was trying to code it so it could just work for horizontal dimensions and here's what i came up with so far. i'm not sure how i tell it to move the object from pt1 to newtxtpt? what do you think?

Code: [Select]
;;pick the text using the node as the point
;;then move the text to the midpoint of the dimension line
;;then move the text down 3-1/2
(defun c:MTOO   (/ txtentity     txtlist
          pt1     dimentity     dimlist    pt2
   txtxcoord     txtycoord  newtxtpt
         )
     (setq txtentity  (car (entsel "\nSelect text: "))
      txtlist    (entget txtentity)
      pt1 (cdr (assoc 10 txtlist))
           )
     (setq dimentity  (car (entsel "\nSelect dimension: "))
      dimlist    (entget dimentity)
      pt2 (cdr (assoc 11 dimlist)))
  )
     (setq txtycoord (cadr (assoc 10 txtlist))
           )
     (setq txtxcoord (car (assoc 11 dimlist))
           )
     (setq newtxtpt (list txtycoord txtxcoord 0)
  )
     (command "move" pt1 newtxtpt)

daron

  • Guest
trying to write my first lisp and i need a bit of help
« Reply #80 on: July 29, 2005, 09:35:34 AM »
I've been waiting for you to come in and while what you've done shows that you're progressing well, your program here is built with a closing parenthesis in the wrong place. It will load, but everything past setq pt2 won't be part of the program as these have become four separate entities. Now, I'm sure the reason you want to jump ahead here and just work for horizontal dimensions is because you want something that works, so you can keep working at work, while continuing to learn and develop a more complete piece of code. So, fix your code above and localize your variables, meaning add variable names to (/ ) <-that area in the defun line. No globals.

I'm not done with you in the direction I want to take you. I see that you understand how to use (command etc...). I'm glad. That means I don't have to teach that. What it does mean is I need to teach you when you don't need to use it. In this training session we're not going to use it unless absolutely necessary. Let's continue. Did you look up subst (substitute), entmod (ENTity MODify), entupd (ENTity UPDate) and cons (CONStruct). This is where we stand.

I did a lot of thinking last night on how to know whether we need to send polar in a negative angle or a positive angle and it's pretty simple, really. Once we get a general direction, we'll get into if, cond and predicate functions.

daron

  • Guest
trying to write my first lisp and i need a bit of help
« Reply #81 on: July 29, 2005, 09:41:56 AM »
OBTW, we are almost done with a quick and dirty working function. There's only a few things left. When we get you something working, really, then we'll get into making sure anybody who gets ahold of it won't come back to you asking why it stopped working when they missed the objects, or that they picked a line instead of a dimesnsion object and it didn't work. At this point, there are many bugs, even though it will work.

daron

  • Guest
trying to write my first lisp and i need a bit of help
« Reply #82 on: July 29, 2005, 09:56:32 AM »
Dan, just a thought. When trying to find misplaced parentheses, start from the inner most nested set of each line and work outward. When you see one that looks like it's in the wrong place it most likely is.

daron

  • Guest
trying to write my first lisp and i need a bit of help
« Reply #83 on: July 29, 2005, 10:02:11 AM »
Dan, I've got some more reading for you to do. Pick the link in here. This should help you navigate the vlide.

ELOQUINTET

  • Guest
trying to write my first lisp and i need a bit of help
« Reply #84 on: July 29, 2005, 10:14:04 AM »
daron i suspected something was wrong but have not been able to figure out how to piece things together. how do i go from line ****** to line________. i havent gotten the parens completely down yet. as i said i have to jump into a job soon so i won't be able to dedicate myself full time to learning for awhile (at least not at work). i hate to bail out on ya but am afraid i must soon.

Code: [Select]
;;pick the text using the node as the point
;;then move the text to the midpoint of the dimension line
;;then move the text down 3-1/2
(defun c:MTOO   (/ txtentity     txtlist
          pt1      dimentity     dimlist    pt2
    txtxcoord     txtycoord  pt3
)
     (setq txtentity  (car (entsel "\nSelect text: "))
      txtlist    (entget txtentity)
      pt1 (cdr (assoc 10 txtlist))
           )
     (setq dimentity  (car (entsel "\nSelect dimension: "))
      dimlist    (entget dimentity)
      pt2 (cdr (assoc 11 dimlist))*************************
  )
     (setq txtycoord (cadr (assoc 10 txtlist))_________________
           )
     (setq txtxcoord (car (assoc 11 dimlist))
           )
     (setq pt3 (list txtycoord txtxcoord 0)
  )
     (command "move" pt1 pt3)

daron

  • Guest
trying to write my first lisp and i need a bit of help
« Reply #85 on: July 29, 2005, 10:27:49 AM »
Let's see if this'll help you out. Look for openings and closings:
Code: [Select]

(defun c:MTOO   (/ txtentity     txtlist
          pt1      dimentity     dimlist    pt2
           txtxcoord     txtycoord  pt3
                             )
     (setq txtentity  (car (entsel "\nSelect text: ")))
      (setq txtlist    (entget txtentity))
      (setq pt1 (cdr (assoc 10 txtlist)))
      (setq dimentity  (car (entsel "\nSelect dimension: ")))
      (setq dimlist    (entget dimentity))
      (setq pt2 (cdr (assoc 11 dimlist))
)
     (setq txtycoord (cadr (assoc 10 txtlist)))
     (setq txtxcoord (car (assoc 11 dimlist)))
     (setq pt3 (list txtycoord txtxcoord 0))
     (command "move" pt1 pt3)

I cleaned up the code a little. Every line, except defun has its opening and closing parenthesis on that line. The code is all indented for easy reading and the misplaced closing parenthesis is also set to show which piece of code it belongs to. You'll see that it's still in the wrong place. Defun (DEfine FUNction) is the least nested piece of code. What I mean by that is all parentheses needed to be in the function need to be contained (nested) within the defun's opening and closing parenthesis. Does that make sense? If you can, print ofs all the information I've asked you to study and over the weekend study it a bit. Post any comments of questions or new understanding you have when you can.

ELOQUINTET

  • Guest
trying to write my first lisp and i need a bit of help
« Reply #86 on: July 29, 2005, 11:05:42 AM »
daron when i load this it loads fine. i pick the text then the text then the dimension and it gives me this error message and i'm not sure what is wrong with this line that is causing it. it is this line, right?

Code: [Select]
 (setq pt3 (list txtxcoord txtycoord 0)
  )


Code: [Select]
(defun c:MTOO (/  txtentity  txtlist pt1   dimentity
      dimlist  pt2     txtxcoord txtycoord  pt3
     )

  (setq txtentity (car (entsel "\nSelect text: "))
txtlist  (entget txtentity)
pt1  (cdr (assoc 10 txtlist))
  )
  (setq dimentity (car (entsel "\nSelect dimension: "))
dimlist  (entget dimentity)
pt2  (cdr (assoc 11 dimlist))
  )
  (setq txtycoord (cadr (assoc 10 pt1))
  )
  (setq txtxcoord (car (assoc 11 pt2))
  )
  (setq pt3 (list txtxcoord txtycoord 0)
  )
  (command "move" pt1 " " pt1 pt3)
)

ELOQUINTET

  • Guest
trying to write my first lisp and i need a bit of help
« Reply #87 on: July 29, 2005, 11:06:22 AM »
whoops  :oops:

ELOQUINTET

  • Guest
trying to write my first lisp and i need a bit of help
« Reply #88 on: July 29, 2005, 11:08:11 AM »
my error message:

Select dimension: ; error: bad association list: (954.876 1028.99 0.0)

daron

  • Guest
trying to write my first lisp and i need a bit of help
« Reply #89 on: July 29, 2005, 11:49:03 AM »
(setq   pt3 (list txtxcoord txtycoord 0))
What I'm seeing here is that your association list is asking for a real number and you've supplied an integer. Try changing it and see what you get. On the other hand, if you have some time, when you're done looking through the assignments I've asked you to look into, minus the vlide editor tutorial, the one we've been working on will also be in working order and it will work on dimensions set at any angle.

The math I worked out yesterday, kept me up. I didn't get much sleep because my mind was still focusing on angular calcs and how we can make this work, while I was trying to sleep. So, because I'm sleep deprived, you owe it to me to find some time to keep this going (keeping your work schedule in check though. I wouldn't want you to get lectured because of me). I'm anxious to give you the code, but I want you to understand it before I do. In fact, it'd be great if you could stumble upon the answers I've got yourself, but I want to guide you. You're doing well. Keep it up and don't let too much time slip by.