+ Reply to Thread
Page 1 of 2 1 2 LastLast
Results 1 to 10 of 15
  1. #1
    Senior Member teknomatika's Avatar
    Using
    AutoCAD 2009
    Join Date
    Sep 2010
    Location
    Portugal
    Posts
    247

    Default Draw near points of text entities

    Registered forum members do not see this ad.

    I look for a routine that will resolve the following task:

    1 - I select a group of text entities (in this case numbers)
    2 - Then I draw a point near the position of one
    3 - Finally, the routine must be able to replicate the point in the other text strings, maintaining the same close relationship defined in step 2

    Attached a drawing to better understand
    Tanks for help!
    Attached Files

  2. #2
    Full Member JamCAD's Avatar
    Discipline
    Civil
    JamCAD's Discipline Details
    Occupation
    Civil Design and Drafting
    Discipline
    Civil
    Using
    AutoCAD 2014
    Join Date
    Aug 2012
    Location
    Brisbane, Australia
    Posts
    75

    Default Try this

    Try this
    Code:
    (defun c:txtpt (/ txt1 txtpt pt ss i ptsz ang dist ip pt1 pt2 pt3 pt4)
      (setq    txt1  (progn (princ "Pick First M/Text Object")
                 (ssget "_+.:E:S" '((0 . "*TEXT")))
              )
        txtpt (cdr (assoc 10 (entget (ssname txt1 0))))
        pt    (getpoint txtpt "\nSelect loction of point")
        ss    (progn (princ "Select All M/Text Objects")
                 (ssget '((0 . "*TEXT")))
              )
        i     0
        ptsz  (getreal "\nHow large should the point be?")
        ang
              (angle txtpt pt)
        dist
              (distance txtpt pt)
      )
      (while (< i (sslength ss))
        (setq ip  (polar
            (cdr (assoc 10 (entget (ssname ss i))))
            ang
            dist
              )
          pt1 (polar ip (/ pi 2) (/ ptsz 2))
          pt2 (polar ip (* pi 1.5) (/ ptsz 2))
          pt3 (polar ip 0 (/ ptsz 2))
          pt4 (polar ip pi (/ ptsz 2))
        )
        (command "line" pt1 pt2 "")
        (command "line" pt3 pt4 "")
        (command "circle" ip (/ ptsz 4))
        (setq i (1+ i))
      )
    )

  3. #3
    Senior Member teknomatika's Avatar
    Using
    AutoCAD 2009
    Join Date
    Sep 2010
    Location
    Portugal
    Posts
    247

    Default

    That's it. However, it is not necessary to draw the symbol as in my example. My intention was that it be interpreted as a point. I just want to be drawn to simple point entity.

    I appreciate the update.
    Last edited by teknomatika; 29th May 2014 at 09:36 am.

  4. #4
    Senior Member teknomatika's Avatar
    Using
    AutoCAD 2009
    Join Date
    Sep 2010
    Location
    Portugal
    Posts
    247

    Default

    I think this way solves what I want.

    Code:
    (defun c:txtpt (/ txt1 txtpt pt ss i ptsz ang dist ip)
      (setq    txt1  (progn (princ "Pick First M/Text Object")
                 (ssget "_+.:E:S" '((0 . "*TEXT")))
              )
        txtpt (cdr (assoc 10 (entget (ssname txt1 0))))
        pt    (getpoint txtpt "\nSelect loction of point")
        ss    (progn (princ "Select All M/Text Objects")
                 (ssget '((0 . "*TEXT")))
              )
        i     0
        ang
              (angle txtpt pt)
        dist
              (distance txtpt pt)
      )
      (while (< i (sslength ss))
        (setq ip  (polar
            (cdr (assoc 10 (entget (ssname ss i))))
            ang
            dist
              )
        )
        (command "point" ip)
        (setq i (1+ i))
      )
    )

  5. #5
    Forum Deity pBe's Avatar
    Computer Details
    pBe's Computer Details
    Operating System:
    Windows 8.1
    Discipline
    Landscape
    Using
    AutoCAD 2015
    Join Date
    Apr 2010
    Posts
    2,951

    Default

    Code:
    (command "point" "_non" ip)

  6. #6
    Senior Member teknomatika's Avatar
    Using
    AutoCAD 2009
    Join Date
    Sep 2010
    Location
    Portugal
    Posts
    247

    Default

    pBe,
    tanks!

  7. #7
    Luminous Being Tharwat's Avatar
    Discipline
    Mechanical
    Tharwat's Discipline Details
    Occupation
    MEP AutoCAD Draughtsman
    Discipline
    Mechanical
    Details
    HVAC, Drainage, Water Supply, Fire Fighting and a little about Electricity.
    Using
    AutoCAD 2015
    Join Date
    Oct 2009
    Location
    Great Syria , Living in Abu Dhabi
    Posts
    6,051

    Default

    Try ..

    Code:
    (defun c:Test (/ *error* c s n sn e aa ab ac)
      ;;    Tharwat 23.05.2014        ;;
      (defun *error* (msg)
        (command "_.ucs" "_w")
        (if c (setvar 'cmdecho c))
        (if (wcmatch (strcase msg) "*BREAK*,*CANCEL*,*EXIT*")
          (princ msg)
          (princ (strcat "Error : < ** " msg " ** >"))
        )
      )
      (if (zerop (getvar 'PDMODE))
        (setvar 'PDMODE 34)
      )
      (setq c (getvar 'cmdecho))
      (setvar 'cmdecho 0)
      (if (setq s (ssget '((0 . "TEXT"))))
        (repeat (setq n (sslength s))
          (setq sn (ssname s (setq n (1- n))))
          (setq e (textbox (list
                             (cons -1 sn)
                           )
                  )
          )
          (command "_.ucs" "Object" sn)
          (setq aa (car e)
                ab (cadr e)
                ac (list (car ab) (cadr aa))
          )
          (command "_.point"
                   "_non"
                   (list (car ac)
                         (- (cadr ac) (/ (cdr (assoc 40 (entget sn))) 2.))
                   )
          )
        )
      )
      (command "_.ucs" "_w")
      (setvar 'cmdecho c)
      (princ)
    )

  8. #8
    Senior Member teknomatika's Avatar
    Using
    AutoCAD 2009
    Join Date
    Sep 2010
    Location
    Portugal
    Posts
    247

    Default

    Tharwat,
    tanks!

    I appreciate the work. As always, perfect.
    It is an interesting option and that also solves my need.
    However, I prefer the solution already presented in this thread, because it allows the set point position for each text string.
    The location of the point shown in the drawing that I have attached, is just one example.
    The main idea is that the position of the point relative to the text string can be pre-defined.
    Last edited by teknomatika; 29th May 2014 at 09:36 am.

  9. #9
    Luminous Being Tharwat's Avatar
    Discipline
    Mechanical
    Tharwat's Discipline Details
    Occupation
    MEP AutoCAD Draughtsman
    Discipline
    Mechanical
    Details
    HVAC, Drainage, Water Supply, Fire Fighting and a little about Electricity.
    Using
    AutoCAD 2015
    Join Date
    Oct 2009
    Location
    Great Syria , Living in Abu Dhabi
    Posts
    6,051

    Default

    Quote Originally Posted by teknomatika View Post
    Tharwat,
    tanks!

    I appreciate the work. As always, perfect.
    It is an interesting option and that also solves my need.
    Happy to hear that .

    Quote Originally Posted by teknomatika View Post
    However, I prefer the solution already presented in this thread, because it allows the set point position for each text string.
    Not a problem , I just wanted to make life easier as best as I can .

    Good luck .

  10. #10
    Quantum Mechanic Lee Mac's Avatar
    Computer Details
    Lee Mac's Computer Details
    Operating System:
    Windows 7 Ultimate (32-bit)
    Discipline
    Multi-disciplinary
    Lee Mac's Discipline Details
    Discipline
    Multi-disciplinary
    Details
    Custom Programming / Software Customisation
    Using
    AutoCAD 2013
    Join Date
    Aug 2008
    Location
    London, England
    Posts
    19,322

    Default

    Registered forum members do not see this ad.

    Here is another way to approach the task:
    Code:
    ;; Text Point  -  Lee Mac
    ;; Prompts the user to specify the location of a point relative to a single text object
    ;; and generates a point in the same location relative to every text object in a selection.
    
    (defun c:txp ( / ang ent enx idx ocs sel vec )
        (while
            (progn (setvar 'errno 0)
                (setq ent (car (entsel "\nSelect source text object: ")))
                (cond
                    (   (= 7 (getvar 'errno))
                        (princ "\nMissed, try again.")
                    )
                    (   (null ent) nil)
                    (   (/= "TEXT" (cdr (assoc 0 (entget ent))))
                        (princ "\nSelected object is not a text object.")
                    )
                )
            )
        )
        (if (and (= 'ename (type ent))
                 (setq vec (getpoint "\nSpecify point: "))
                 (setq sel (ssget '((0 . "TEXT"))))
            )
            (progn
                (setq
                    enx (entget ent)
                    ang (cdr (assoc 050 enx))
                    ocs (cdr (assoc 210 enx))
                    vec
                    (mxv
                        (mxm
                            (list
                                (list (/ 1.0 ((lambda ( box ) (- (caadr box) (caar box))) (textbox enx))) 0.0 0.0)
                                (list 0.0 (/ 1.0 (cdr (assoc 040 enx))) 0.0)
                               '(0.0 0.0 1.0)
                            )
                            (mxm
                                (list
                                    (list (cos ang)     (sin ang) 0.0)
                                    (list (- (sin ang)) (cos ang) 0.0)
                                   '(0.0 0.0 1.0)
                                )
                                (mapcar '(lambda ( v ) (trans v ocs 0 t))
                                   '(
                                        (1.0 0.0 0.0)
                                        (0.0 1.0 0.0)
                                        (0.0 0.0 1.0)
                                    )
                                )
                            )
                        )
                        (mapcar '- (trans vec 1 0) (trans (cdr (assoc 10 enx)) ent 0))
                    )
                )
                (repeat (setq idx (sslength sel))
                    (setq enx (entget (ssname sel (setq idx (1- idx))))
                          ang (cdr (assoc 050 enx))
                          ocs (cdr (assoc 210 enx))
                    )
                    (entmake
                        (list
                           '(0 . "POINT")
                            (cons 10
                                (mapcar '+ (trans (cdr (assoc 10 enx)) ocs 0)
                                    (mxv
                                        (mxm
                                            (mapcar '(lambda ( v ) (trans v 0 ocs t))
                                               '(
                                                    (1.0 0.0 0.0)
                                                    (0.0 1.0 0.0)
                                                    (0.0 0.0 1.0)
                                                )
                                            )
                                            (mxm
                                                (list
                                                    (list (cos ang) (- (sin ang)) 0.0)
                                                    (list (sin ang)    (cos ang)  0.0)
                                                   '(0.0 0.0 1.0)
                                                )
                                                (list
                                                    (list ((lambda ( box ) (- (caadr box) (caar box))) (textbox enx)) 0.0 0.0)
                                                    (list 0.0 (cdr (assoc 040 enx)) 0.0)
                                                   '(0.0 0.0 1.0)
                                                )
                                            )
                                        )
                                        vec
                                    )
                                )
                            )
                        )
                    )
                )
            )
        )
        (princ)
    )
    
    ;; Matrix Transpose  -  Doug Wilson
    ;; Args: m - nxn matrix
    
    (defun trp ( m )
        (apply 'mapcar (cons 'list m))
    )
    
    ;; Matrix x Matrix  -  Vladimir Nesterovsky
    ;; Args: m,n - nxn matrices
    
    (defun mxm ( m n )
        ((lambda ( a ) (mapcar '(lambda ( r ) (mxv a r)) m)) (trp n))
    )
    
    ;; Matrix x Vector  -  Vladimir Nesterovsky
    ;; Args: m - nxn matrix, v - vector in R^n
    
    (defun mxv ( m v )
        (mapcar '(lambda ( r ) (apply '+ (mapcar '* r v))) m)
    )
    
    (princ)
    The above will account for the varying position, rotation, width, height & orientation of every text object in the selection, and will also perform correctly under all UCS & View settings.
    Lee Mac ProgrammingTwitterExchange App StoreDropbox (500MB free)

    With Mathematics there is the possibility of perfect rigour, so why settle for less?

Similar Threads

  1. adding text entities
    By Jessica28 in forum AutoLISP, Visual LISP & DCL
    Replies: 11
    Last Post: 18th Mar 2014, 11:21 am
  2. Place points on all Autocad entities
    By 4DCES in forum AutoLISP, Visual LISP & DCL
    Replies: 10
    Last Post: 6th Feb 2012, 02:22 pm
  3. Selecting entities using the draw order
    By teknomatika in forum AutoLISP, Visual LISP & DCL
    Replies: 6
    Last Post: 13th Apr 2011, 08:48 pm
  4. autolisp routine to read coordinates and insert entities points
    By teknomatika in forum AutoLISP, Visual LISP & DCL
    Replies: 7
    Last Post: 22nd Sep 2010, 06:51 pm
  5. [Civil 3d 2009] arrange cogo points entities
    By coeziv in forum Civil 3D & LDD
    Replies: 6
    Last Post: 25th Mar 2009, 03:30 am

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts