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

0 Members and 1 Guest are viewing this topic.

Eloquintet

  • Gator
  • Posts: 3206
trying to write my first lisp and i need a bit of help
« Reply #90 on: July 29, 2005, 11:51:37 AM »
daron i got it to work sorta. it moves the text but the text is actually left justified not center so it places the text off center to the right. also i noticed that depending on the zoom it places the text in a different location. the first part of the question concerns assoc 72 right but once i extract the info i need how do i group that with the 10 coordinates and carry that info to the end of the routine. a list i suppose. i'll play around with it over the weekend and read the topics you suggested. thanks a bunch for your help i know it's not easy slowing to a crawl.

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 txtxcoord (car pt2)
  )
  (setq txtycoord (cadr pt1)
  )
  (setq pt3 (list txtxcoord txtycoord 0)
  )
  (command "move" pt1 "" pt1 pt3)
Dan

AutoCAD Architecture 2015

daron

  • Guest
trying to write my first lisp and i need a bit of help
« Reply #91 on: July 29, 2005, 12:08:07 PM »
I was wondering when we'd hit that roadblock. For the time being, there's an express tool called justify text you might use before issuing your code. When you get more time, we can then tackle moving the text from the middle of the length x half the height of the text to the point you want.

Eloquintet

  • Gator
  • Posts: 3206
trying to write my first lisp and i need a bit of help
« Reply #92 on: July 29, 2005, 01:16:27 PM »
daron i discovered that it not putting the second text in the right position had something to do with osnap being on so i turned it off then back on and it works for now. we'll improve upon this when i get another free moment but i must get back to work now. thanks you for all of your help you're a saint  :wink:

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)
 
  (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" 127)
  (princ)
)
Dan

AutoCAD Architecture 2015

daron

  • Guest
trying to write my first lisp and i need a bit of help
« Reply #93 on: July 29, 2005, 02:05:13 PM »
:lol:

As for the code, try this:
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)
)

That was something I was aware of. I wanted you to find it and you did. Good call. Now, if you want to set it to what was previously set, it will be, even if it was 127 to begin with.