Jump to content

Insert value returned by lisp to drawing on screen


Recommended Posts

Posted
Don't forget about ACET-SS-Drag-Move. I only suggest this to allow the user the ability of being able to utilize OSnaps normally and avoid the annoyances of a right-click if using Move..Pause. However, it does require Express Tools to be loaded.

 

Nice one mate - completely forgot about that one!

  • Replies 35
  • Created
  • Last Reply

Top Posters In This Topic

  • sadhu

    13

  • alanjt

    12

  • Lee Mac

    11

Posted

An example for you to play with Sadhu :)

 

(defun c:test (/ Move ss p1 p2)
 (vl-load-com)

 (defun Move (ss p1 p2 / i ent)
   (setq i -1)
   (while (setq ent (ssname ss (setq i (1+ i))))
     (vla-move (vlax-ename->vla-object ent)
               (vlax-3D-point p1)
               (vlax-3D-point p2))))  

 (if (and (setq ss (ssget))
          (setq p1 (getpoint "\nPick Base Point: "))
          (setq p2 (acet-ss-drag-move ss p1 "\nSpecify Second Point: " t)))
   (Move ss p1 p2))

 (princ))

Posted
(defun c:test (/ Move ss p1 p2)
 (vl-load-com)

 (defun Move (ss p1 p2 / i ent)
   (setq i -1)
   (while (setq ent (ssname ss (setq i (1+ i))))
     (vla-move (vlax-ename->vla-object ent)
               (vlax-3D-point p1)
               (vlax-3D-point p2))))  

 (if (and (setq ss (ssget))
          (setq p1 (getpoint "\nPick Base Point: "))
          (setq p2 (acet-ss-drag-move ss p1 "\nSpecify Second Point: " t)))
   (Move ss p1 p2))

 (princ))

Thanks, I'll work on that.

Posted
Nice one mate - completely forgot about that one!

It's just so useful. :)

Posted

Not very satisfying but I managed it like this. It selects the last object inserted and moves it.

 

I had to replace "ss" with "ss1" but didn't understand the difference. Is it possible to make "entmakex" invisible ?

 

(and
   (setq pnt
      (getpoint
        "\nPunto di inserimento misura / Specify Text placement point: "
      )
   )
   (entmakex
     (list '(0 . "MTEXT")
       '(100 . "AcDbEntity")
       '(100 . "AcDbMText")
       ;(cons 8 lay)
       (cons 1 result)
       (cons 7 (getvar 'textstyle))
       (cons 10 pnt) ;point of insertion
       (cons 40 0.08)
     ) ;_ list
   ) ;_ entmakex
 ) ;_ and

                   
                     ;------------------------


(defun Move (ss1 p1 p2 / i ent)
   (setq i -1)
   (while (setq ent (ssname ss1 (setq i (1+ i))))
     (vla-move (vlax-ename->vla-object ent)
               (vlax-3D-point p1)
               (vlax-3D-point p2))))  
 (if (and (setq ss1 (ssget [color=Red]"L"[/color]))
          ;(setq p1 (getpoint "\nPick Base Point: "))
          (setq p2 (acet-ss-drag-move ss1 [color=Red]pnt [/color]"\nSpecify Second Point: " t 0)))
   (Move ss1 [color=Red]pnt[/color] p2))

 (princ)

Posted

I would perhaps rewrite it something like this:

 

(setq dummyss (ssadd))

(and (setq Pt1 (getpoint "\nPunto di inserimento misura / Specify Text placement point: "))
    (setq ent (entmakex (list (cons 0 "MTEXT")
                              (cons 100 "AcDbEntity")
                              (cons 100 "AcDbMText")
                              (cons 1 result)
                              (cons 7 (getvar 'textstyle))
                              (cons 10 Pt1) ;point of insertion
                              (cons 40 0.08))))
    
    (setq Pt2 (acet-ss-drag-move (ssadd ent dummyss) Pt1 "\nSpecify Second Point: " t 0))
    (vla-move (vlax-ename->vla-object ent)
              (vlax-3D-point Pt1)
              (vlax-3D-point Pt2)))

Posted

For a single object, you don't have to worry with creating a stored ssadd variable.

 

(and (setq Pt1 (getpoint "\nPunto di inserimento misura / Specify Text placement point: "))
    (setq ent (entmakex (list (cons 0 "MTEXT")
                              (cons 100 "AcDbEntity")
                              (cons 100 "AcDbMText")
                              (cons 1 result)
                              (cons 7 (getvar 'textstyle))
                              (cons 10 Pt1) ;point of insertion
                              (cons 40 0.08))))
    
    (setq Pt2 (acet-ss-drag-move (ssadd ent) Pt1 "\nSpecify Second Point: " t 0))
    (vla-move (vlax-ename->vla-object ent)
              (vlax-3D-point Pt1)
              (vlax-3D-point Pt2)))

Posted
Ooo didn't know that - thanks Alan :thumbsup:

:)

Welcome.

Posted

(and (setq Pt1 (getpoint "\nPunto di inserimento misura / Specify Text placement point: "))
    (setq ent (entmakex (list (cons 0 "MTEXT")
                              (cons 100 "AcDbEntity")
                              (cons 100 "AcDbMText")
                              (cons 1 result)
                              (cons 7 (getvar 'textstyle))
                              (cons 10 Pt1) ;point of insertion
                              (cons 40 0.08))))
    
    (setq Pt2 (acet-ss-drag-move (ssadd ent) Pt1 "\nSpecify Second Point: " t 0))
    (vla-move (vlax-ename->vla-object ent)
              (vlax-3D-point Pt1)
              (vlax-3D-point Pt2)))

Your code is definitely more "elegant", compact and works fine. However it behaves in the same manner as the one I wrote/compiled - it was your code anyway.

 

Thanks a lot :D.

 

Any suggestions to rotate text - (ent) ?

Posted

Got to thank both of you . This site updates damn too fast.

Posted
(and (setq Pt1 (getpoint "\nPunto di inserimento misura / Specify Text placement point: "))
    (setq ent (entmakex (list (cons 0 "MTEXT")
                              (cons 100 "AcDbEntity")
                              (cons 100 "AcDbMText")
                              (cons 1 result)
                              (cons 7 (getvar 'textstyle))
                              (cons 10 Pt1) ;point of insertion
                              (cons 40 0.08))))
    
    (setq Pt2 (acet-ss-drag-move (ssadd ent) Pt1 "\nSpecify Second Point: " t 0))
    (not (vla-move (vlax-ename->vla-object ent)
              (vlax-3D-point Pt1)
              (vlax-3D-point Pt2)))
    (setq Rot (acet-ss-drag-rotate (ssadd ent) Pt2 "Specify angle: " T 0))
    (vla-put-rotation (vlax-ename->vla-object ent) Rot))

Posted

Just tried it. Works great. :D Thanks Alan.

 

Do I have the "quote the code" every time I post a reply - like below ?

 

(and (setq Pt1 (getpoint "\nPunto di inserimento misura / Specify Text placement point: "))
    (setq ent (entmakex (list (cons 0 "MTEXT")
                              (cons 100 "AcDbEntity")
                              (cons 100 "AcDbMText")
                              (cons 1 result)
                              (cons 7 (getvar 'textstyle))
                              (cons 10 Pt1) ;point of insertion
                              (cons 40 0.08))))
    
    (setq Pt2 (acet-ss-drag-move (ssadd ent) Pt1 "\nSpecify Second Point: " t 0))
    (not (vla-move (vlax-ename->vla-object ent)
              (vlax-3D-point Pt1)
              (vlax-3D-point Pt2)))
    (setq Rot (acet-ss-drag-rotate (ssadd ent) Pt2 "Specify angle: " T 0))
    (vla-put-rotation (vlax-ename->vla-object ent) Rot))

Posted

Doesn't seem to work when I add the layer option.


[color=Red](setq lay "MEASURE Layer" )[/color]

(and (setq Pt1 (getpoint "\nPunto di inserimento misura / Specify Text placement point: "))
    (setq ent (entmakex (list (cons 0 "MTEXT")
                              (cons 100 "AcDbEntity")
                              (cons 100 "AcDbMText")
                             [color=Red] (cons 8 lay)[/color]
                              (cons 1 result)
                              (cons 7 (getvar 'textstyle))
                              (cons 10 Pt1) ;point of insertion
                              (cons 40 0.08))))
    
    (setq Pt2 (acet-ss-drag-move (ssadd ent) Pt1 "\nSpecify Second Point: " t 0))
    (not (vla-move (vlax-ename->vla-object ent)
              (vlax-3D-point Pt1)
              (vlax-3D-point Pt2)))
    (setq Rot (acet-ss-drag-rotate (ssadd ent) Pt2 "Specify angle: " T 0))
    (vla-put-rotation (vlax-ename->vla-object ent) Rot))

Posted

Sorry for that fast post. It really works with the layer option too.

Posted
Just tried it. Works great. :D Thanks Alan.

 

Do I have the "quote the code" every time I post a reply - like below ?

 

 

 

:) You're welcome and no, you don't have to post the same in a reply.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...