Author Topic: text move lisp in need of enhancement  (Read 13941 times)

0 Members and 1 Guest are viewing this topic.

ELOQUINTET

  • Guest
text move lisp in need of enhancement
« on: August 02, 2005, 01:57:03 PM »
i was working on this lisp with daron but had to take a little break. now i am ready to give it some enhancements and need some hints. here is a list of things which need improving:

1 the text is left justified so it first needs to be converted to center so when it is moved it is centered

2 this routine currently only works on horizontal dimensions but also needs to work on vertical and aligned.

that's all i can come up with right away. can daron or anyone help me continue this exercise.

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:MTO ( / txtentity txtlist dimentity dimlist txtxcoord txtycoord pt1 pt2 pt3)
   (setq osm (getvar 'osmode))
  (setvar "osmode" 0)
  (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   txtxcoord (car pt2)
  )
  (setq   txtycoord (cadr pt1)
  )
  (setq   pt3 (list txtxcoord txtycoord 0)
  )
  (command "move" pt1 "" pt1 pt3)
  (setvar 'osmode osm)
  (princ)
)

daron

  • Guest
text move lisp in need of enhancement
« Reply #1 on: August 02, 2005, 01:58:56 PM »
Dan, if we could get back to where we left off, you'd have what you need, except the text justification portion, all of which, I've been waiting to continue with.

ELOQUINTET

  • Guest
text move lisp in need of enhancement
« Reply #2 on: August 02, 2005, 02:27:49 PM »
i thought we touched on the angle and polar functions in order to be able to do other dim types but never really applied them. i will read over them now to try to make sense of them. should i look at how testing is done using if and then or cond or is it too early to explore that. i'm not sure about the structuring of that so i may have a peak. thanks for returning to help me finish this off by the way.

daron

  • Guest
text move lisp in need of enhancement
« Reply #3 on: August 02, 2005, 03:16:55 PM »
I just went through a discourse on all we have left, but closed that tab accidentally. I don't have time to rewrite it, but will later. In the mean time, I'd like to get this discussion back on the previous lesson, so as to keep everything in one place. We are going to be getting into constant, variable and included angles. I believe the word theta comes to play. To see what I mean, look at >this< taken from Stig's website.

ELOQUINTET

  • Guest
text move lisp in need of enhancement
« Reply #4 on: August 02, 2005, 04:17:25 PM »
ok i've read through it and duplicated his drawing but i get lost when i reach the math part as i didn't get very far in math. my problem with all of this is that i have trouble interpretting named data without having to go back and see what the values are and then when i get back to the summarized part i forget what i was looking at and why. i guess the more code i look at the easier it will be to process (somethings are already easier) but right now that's too much for me to process. i think i understand the need for it in my routine. the line in this example would be my dimension line and selecting that line would apply pt1 and pt2 to its endpoints and extract the angle whatever it maybe. am i close???

daron

  • Guest
text move lisp in need of enhancement
« Reply #5 on: August 02, 2005, 04:33:04 PM »
Very. However, I didn't expect you to duplicate what he had. I'm not to familiar with theta myself, but the word is in there and implies your included angle which I mean angle (GC14 GC13) from (GC14 GC10). All we then have to do is find out whether or not the included angle is positive or negative and we know which direction to go. When we finish, you'll see that it's far easier than it sounds and Stig's example I sent you to will look like MAJOR overkill, but then we're only taking a very small portion of it.

ELOQUINTET

  • Guest
text move lisp in need of enhancement
« Reply #6 on: August 02, 2005, 04:36:40 PM »
i notice that pt1 and pt2 are interpreted differently depending on which end i choose to draw the line from and the same for the dimension. if i start from the bottom it interprets the bottom point as pt1 and the top as pt2 but if i draw the line from top to bottom it does the reverse. and how does the circle play into my routine because if the dimension doesn't cross the circle it picks the point on the dimension line just below the text. is this so if the dimension text is out of the default position it will still put the text below it?

ELOQUINTET

  • Guest
text move lisp in need of enhancement
« Reply #7 on: August 02, 2005, 04:41:47 PM »
it wasn't hard to duplicate and seeing it in action and playing with it helped me better analyze why we would need it. i need all the visual aids i can get  :)

daron

  • Guest
text move lisp in need of enhancement
« Reply #8 on: August 02, 2005, 04:51:17 PM »
You're taking too much of his example into it. All you need from his example, besides the fact that everything comes down to angles and circles is the theta or included angle. Chew on this for a bit and explain it:
Code: [Select]

     (setq constangle (angle dimassoc14 dimassoc10)
      varangle   (angle dimassoc14 dimassoc13)
      inclangle  (- constangle varangle)
     )

As well, this portion that we already have:
Code: [Select]
(setq txt2dimang (angle dimassoc10 dimassoc14)
So, you see, you're right, we do need GC10 and 14 going both ways? Why? I'll answer: 14 to 10 allows you to get the included angle when you subtract GC14 and 13 from it. 10 to 14 gives you the angle we need and the point from which to go from.

ELOQUINTET

  • Guest
text move lisp in need of enhancement
« Reply #9 on: August 02, 2005, 07:59:36 PM »
i knew not all of it applied but wasn't sure which did and which didn't but believe your hint will help me. i need to look at that and then look back to see what 10 13 and 14 refer to then apply it. i'll be chewin that tonight (and hopefully not gagging) and will give my interpretation tomorrow.

ELOQUINTET

  • Guest
text move lisp in need of enhancement
« Reply #10 on: August 03, 2005, 09:44:57 AM »
ok daron i've digested those bits. so essentially we will be aquiring 3 point which can be used to determine the angle of the dimension. we will determine constangle. then varangle then subtract varangle to get the inclangle. correct?

daron

  • Guest
text move lisp in need of enhancement
« Reply #11 on: August 03, 2005, 02:28:22 PM »
Yes. I'm not ignoring you today. I just have something that's not working, so sometimes it's best to get away from it.

ELOQUINTET

  • Guest
text move lisp in need of enhancement
« Reply #12 on: August 03, 2005, 02:33:36 PM »
it's alright daron i kinda felt like i was ignoring you because my boss is not in today so i have been developing some dynamic blocks. i'm trying to figure out what keeps triggering this fatal error i get after adding a stretch param when my blocks get complicated. anyway no worries do whatcha gotta do.

ELOQUINTET

  • Guest
text move lisp in need of enhancement
« Reply #13 on: August 04, 2005, 09:40:24 AM »
daron i tried to plug in the info you gave me but i dont think i got it quite right. the lisp loads fine but when i select the dimension it returns this message:

Select dimension: ; error: bad argument type: 2D/3D point: nil

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:MTO2 ( / txtentity txtlist dimentity dimlist txtxcoord txtycoord txt2dimang constangle varangle inclangle pt1 pt2 pt3)
 
    (setq osm (getvar 'osmode))
    (setvar "osmode" 0)
    (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 txtxcoord (car pt2)
  )
    (setq txtycoord (cadr pt1)
  )
    (setq pt3 (list txtxcoord txtycoord 0)
  )
    (setq txt2dimang (angle dimassoc10 dimassoc14)
  )
    (setq constangle (angle dimassoc14 dimassoc10)
  )
    (setq varangle   (angle dimassoc14 dimassoc13)
  )
    (setq inclangle  (- constangle varangle)
  )
    (command "move" pt1 "" pt1 pt3)
    (setvar 'osmode osm)
  (princ)
)

daron

  • Guest
text move lisp in need of enhancement
« Reply #14 on: August 04, 2005, 09:52:45 AM »
Well, it will be somewhat flawed still, but when issuing the command "Move", your first variable should be an ename, not an elist and definately not a sublist within that list, which is what you've supplied. By the end of the day, I should have something to take us to the next level. I think you're starting to get the idea here though. Have you looked at Entmod, Subst and Entupd? Please do and post your understandings. Also, read up on if and cond. Again, post your findings.