Jump to content

Dimensions to Mtext


dbgeek

Recommended Posts

I have not written any lisp files for about 5 years so I am a little rusty.

 

I want to use a lisp function add a text box to a drawing with a few variables in it.

I have most of it working but I have a couple small problems.

When I have finished a flat pattern for cnc cutting I currently add some information to the bottom of the drawing for the machine operator, so I have decided to speed things up a bit with a lisp function.

 

The first part is used to draw two lines across the length and width of the pattern then I click on those lines to get their properties for the text box.

I would prefer to use two pick points like lower left and upper right to get the size but I don't know how to do this.

 

The other problem is I want to add 50mm to each of the values into a line that says sheet size but I could not get any equations to work.

 

Any help would be appreciated.

 

Thanks

 

(defun c:l2(/ lSel hsel spt lLen hlen)
(vl-load-com)
;Draw construction lines
(setq previouslayer (getvar "clayer"))
(command "-Layer" "Set" "Defpoints" "")
(command "_line" pause pause "")
(command "_line" pause pause "")
(command "-Layer" "Set" previouslayer "")
;select construction lines
 (if (and
          (setq lSel (entsel "\nSelect length"))
          (setq hSel (entsel "\nSelect height"))
      )
;Get selected line info
   (progn
;length
     (setq lObj
                (vlax-ename->vla-object(car lSel))
               sPt
                (cadr lSel)
               lLen ; Length
                (rtos (vla-get-Length lObj))
               )
;height
     (setq lObj
                (vlax-ename->vla-object(car hSel))
               sPt
                (cadr hSel)
               hLen ; Height
                (rtos (vla-get-Length lObj))
               )
;Place data in mtext box
(setq previouslayer (getvar "clayer"))
(command "-Layer" "Set" "TEXT" "")
     (command "_mtext" pause "s" "standard" "h" "20" "w" "500"              
              (strcat (getvar "dwgname"))
              (strcat (menucmd "M=$(edtime,$(getvar,date),D MON YY )"))
              (strcat "Length = " lLen )
              (strcat "Height = " hLen)
              (strcat "Sheet = " )
              (strcat "Drawn By "(getvar "loginname"))
                  ""); end command
(command "-Layer" "Set" previouslayer "")
     ); end progn
   );end if
 (princ)
 ); end

Link to comment
Share on other sites

Ok

 

It appears that nobody can help me with this but I have figured it out so I will post it in case it helps somebody.

 

; mtext info for plasma operator 10 high
(defun c:l10()
(setq point1 (getpoint "\nBottom Left Point"))
(setq point2 (getpoint point1 "\nTop Right Point"))
(setq point1X (car point1))
(setq point2X (car point2))
(setq Xdist (- point2X point1X))
(setq point1Y (cadr point1))
(setq point2Y (cadr point2))
(setq Ydist (- point2Y point1Y))
(command "-Layer" "Set" "TEXT" "")
     (command "_mtext" pause "s" "standard" "h" "10" "w" "500"              
              (strcat (getvar "dwgname"))
              ;(strcat "By "(getvar "loginname"))
              (strcat (menucmd "M=$(edtime,$(getvar,date),D MON YY )"))
              (strcat "Length = " (rtos XDIST 2 1) )
              (strcat "Height = " (rtos YDIST 2 1) )
              " "
              (strcat "Sheet = " (rtos(+ xdist 50) 2 1) " X " (rtos(+ ydist 50) 2 1) )
                  ""); end command
(command "-Layer" "Set" previouslayer "")
 (princ)
 ); end

Link to comment
Share on other sites

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...