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

0 Members and 1 Guest are viewing this topic.

ELOQUINTET

  • Guest
trying to write my first lisp and i need a bit of help
« Reply #45 on: July 27, 2005, 03:56:36 PM »
something like this. i was trying to figure out how to get pt2. i thought it would be the same idea but i am not sure how to join the 2 parts or if the dxf code is right. maybe i'm wrong but i'm playing around with it:

Code: [Select]
c:mto (/txtname pt1 dimname pt2)
     (setq txtname (car (entsel "\nSelect text: ")) ;;we save the txtname
              txtlist (entget txtname) ;;we have the txtlist and want to get the txtname we need from the list
              pt1 (cdr (assoc 10 txtlist));;we break this down to only the coordinates
     (setq dimname (car (entsel "\nSelect text: ")) ;;we get the dimname
              dimlist (entget dimname) ;;we have the dimname and want to get the dimname we need from the list
              pt2 (cdr (assoc 1 dimlist))
     )

ELOQUINTET

  • Guest
trying to write my first lisp and i need a bit of help
« Reply #46 on: July 27, 2005, 03:57:21 PM »
thanks for not laughing yet by the way  :oops:

ELOQUINTET

  • Guest
trying to write my first lisp and i need a bit of help
« Reply #47 on: July 27, 2005, 04:00:28 PM »
i am testing the dimension text the same way i looked at the plain text and come up with this.

Command: (entsel "\nSelect text: ")

Select text: (<Entity name: 7ef97738> (1083.3 820.807 0.0))


can you look at my comments and help me because i don't think that's what's happening

daron

  • Guest
trying to write my first lisp and i need a bit of help
« Reply #48 on: July 27, 2005, 04:06:14 PM »
MP, we'll get there. I was leaving error trapping out as that can be more confusing than me to a beginner. Please continue to add your comments, though. I certainly don't want to squander any growth or understanding that Dan can get from others.


Try to set up the exercise I've given >here< to getting dimension elist. If you want, you can create a whole new USUBR for it and maybe we'll get into calling external routines and the importance of return values.

ELOQUINTET

  • Guest
trying to write my first lisp and i need a bit of help
« Reply #49 on: July 27, 2005, 04:15:04 PM »
ok i'm getting spun around and don't know what's going on. mp i can kinda see what you're getting at and i do appreciate the advice. daron the link you posted is to this page where i don't see the exercise you're talking about. did you see what i tried. not sure where to go?

daron

  • Guest
trying to write my first lisp and i need a bit of help
« Reply #50 on: July 28, 2005, 08:18:14 AM »
I didn't see your post Dan. I was trying to point to this page so my post wouldn't get lost in the shuffle. It appears that you did try to get the dimension object. Here's the issues I have:
1) you've got a setq that doesn't need to be there or you need to close out the first one before starting a new one.
2) I know your initial intention is:
Quote
move the text to the midpoint of the dimension line
then move the text down 3-1/2

but we're not going to do this any conventional way. What we're going to do is get points and substitute the point list we come up with in the dimension for the current point list of the text. I know this doesn't make much sense, but as we go you'll get the picture.


I should probably let you find the bugs, but I'm going to post what we have to date and add what you were trying to do with some extra items to think about.
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:MoveTextToDimension (/       txtentity     txtlist
txtassoc10    dimentity     dimlist
dimassoc10    dimassoc11    dimassoc13
dimassoc14    dimassoc42
)
     (setq txtentity  (car (entsel "\nSelect text: "))
  txtlist    (entget txtentity)
  txtassoc10 (cdr (assoc 10 txtlist))
     )
     (setq dimentity  (car (entsel "\nSelect dimension: "))
  dimlist    (entget dimentity)
  dimassoc10 (cdr (assoc 10 dimlist))
  dimassoc11 (cdr (assoc 11 dimlist))
  dimassoc13 (cdr (assoc 13 dimlist))
  dimassoc14 (cdr (assoc 14 dimlist))
  dimassoc42 (cdr (assoc 42 dimlist))
     )
)

I changed some of the variable names. On the new portion test each dimassoc value. Look for their meanings in the dxf reference area under common dimension group code under Dimension under Entities. Some we'll use, some we won't. This may be a difficult task, but can you find which one's we won't need? One way to see what each point does minus 42 is inspect that setq block making that block global. Then, in autocad draw lines. When it asks for points as the line command does, supply !dimassoc10, !dimassoc11, etc. 42 is not a point value, so this one won't work. I put it in there because we're definately going to need it. What we won't need are two of the others. Study it a bit and tell me what you think.

I changed the name too. If you want to set it back to three letters, do this:
Code: [Select]
(defun c:mto () (c:MoveTextToDimension) (princ))

daron

  • Guest
trying to write my first lisp and i need a bit of help
« Reply #51 on: July 28, 2005, 08:23:50 AM »
Code: [Select]
;;pick the text using the node as the point
Just had a thought. Maybe this'll pique some light. The user currently can select a piece of text and we've supplied a point value. This point value is not the node as you'd normally use it, though it is most likely the same point you'd normally pick. One thing we're not going to do here is use any osnaps. Don't worry, we're still going to get the precision that osnaps give you. Also, when we're done here, your code will not have command in it, except maybe (command ".undo" "be") and (command ".undo" "e"), if we choose to use that. There're some fun exercises in there too if we don't.

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
trying to write my first lisp and i need a bit of help
« Reply #52 on: July 28, 2005, 09:12:45 AM »
Quote from: daron
MP, we'll get there. I was leaving error trapping out as that can be more confusing than me to a beginner.

Sorry, I shouldn't haved butted in, but I couldn't help myself. The pace you're conducting is fine Daron. Kudos to you for taking the initiative to  help out Dan like this.
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

daron

  • Guest
trying to write my first lisp and i need a bit of help
« Reply #53 on: July 28, 2005, 09:44:41 AM »
Thanks. Don't worry about butting in. I may need help teaching and someone like yourself can bring it to a level I may not be able. Plus, sometimes I tend to add too much information, thus overwhelming the person I'm trying to teach. I'm trying very hard to keep it toned down for Dan and I'm glad he came up with something that he needs that doesn't have to be TALL order, even though it could certainly become tall order when we get into "user friendliness" and portability. I don't mean portability like from one OS to another, just from one users idea of how it should work and anothers. Finding all the ways a dimension needs to be handled will certainly add to the height of the order, but it will also lead Dan down the road to understanding a great deal more than he thought possible.

Dan, don't feel overwhelmed here if you're not remembering things. I know I didn't get it after one or two lisps. I'd ask questions of the same things. When I started writing function repetedly, is when I started understanding how they work. You'll use things like entsel, cdr, car, entget and assoc so regular that eventually you'll know exactly what it is you need and you'll wonder how you ever didn't know.

ELOQUINTET

  • Guest
trying to write my first lisp and i need a bit of help
« Reply #54 on: July 28, 2005, 09:46:29 AM »
daron i see that 10 is the endpoint of the dimension line, 11 is the midpoint of the text, and 13 and 14 are the left and right origin points of the dimension. i think we need 11 but not sure what else, you said we need 2? i see what you mean about not needed osnaps or commands we can just grab and place the entity where we want with the code so we dont need a conventional move command persay.

ELOQUINTET

  • Guest
trying to write my first lisp and i need a bit of help
« Reply #55 on: July 28, 2005, 09:55:18 AM »
ah missed the new posts. i'm so glad i have this place to learn. i'm picking things up little by little and like you say eventually i'll just be able to hop on the bike and off i go. the good thing is i am aware of the possibilities from seeing the stuff coded here and i'm excited about the future and proud of myself for making the leap into learning how to do for myself.

daron

  • Guest
trying to write my first lisp and i need a bit of help
« Reply #56 on: July 28, 2005, 10:17:17 AM »
Yeee-Hawww.
Code: [Select]
;;then move the text to the midpoint of the dimension line
We're not going to move the text to the midpoint of the DIMENSION line, but we are going to get that point. This is the point we're about to get.

Okay Dan. I'm going to spell it out for you now. I see that you tried and since you can't look into my mind to see where I'm going to go with this this'll take a load off. Okay, let's see; when I was testing this, I was looking into finding the midpoint of the dimline by using 10 and 11. 11 isn't the middle of the dimension line as I understand it, but the middle of the dimension text. So, if the text is not in the middle of the dimension line, you're going to have trouble. Now, if you move your dimensions and you want the text we're moving below the dimtext, then we're going to have to go the GC11 route, but for now, I'd like to assume you're not concerned with that and we're going to go a slightly different direction, which will give you knowledge of some more functions that as you begin to understand, you'll want to use commonly. Also, I found some quirky things happening when trying to subtract some values from pt10 and pt11. So, to avoid the conflict I had, we're going to alter the course and make sure we get the points we need which by your criteria, is the middle of the dimension line.

Okay, I said I'd spell it out for you, so here it is. We do need GC10, but let's look at GC14. GC14 is origin point along the same line as 10, so you have a common line to all dimensions here. I just stumbled across a little issue. I went back and tested something and it appears we'll need GC13 as well, but let's not worry about that right now. I'll explain later. Right now, I want you to look at a couple of help topics: angle and polar. Read up on these and see if you can make sense of them. I can't find polar in any of Stig's lesson's. If you can great, otherwise just try and tell us what you find concerning polar and angle and we can move ahead.

Quote from: Dan
and proud of myself for making the leap into learning how to do for myself.
I'm sure many of us are too. As well, when you do have a more sound understanding, you'll be able to pitch in with some help to others, which is the greatest benefit.

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
trying to write my first lisp and i need a bit of help
« Reply #57 on: July 28, 2005, 10:49:50 AM »
Suggestion: After the dxf coding techniques are explored parallel functionality using activex techniques should be discussed.
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

daron

  • Guest
trying to write my first lisp and i need a bit of help
« Reply #58 on: July 28, 2005, 10:53:48 AM »
You don't think it's too early? I was thinking get him on solid ground first. I'll see what I can do with AX.

ELOQUINTET

  • Guest
trying to write my first lisp and i need a bit of help
« Reply #59 on: July 28, 2005, 11:02:40 AM »
let's just say i could use 11 because i highly doubt this dimension text will bee moved from it's default. i know you are trying to error trap but on the other hand do we really need to complicate it that much. i'm willing to learn the error free way it was just a thought. not sure why we need 10, 13, and 14 but i'll trust ya you're the teacher.  :lol: ok i'm not sure where in help you want me to look for angle and polar and what aspects of angle/polar should i be looking at?