Jump to content

Recommended Posts

Posted

I want to make a script, which creates a square, where lines are joined, and corner are filled radius 5

 

And further more a text in the middle of the square

 

Here is what i got so far

_line 0,0 560,0 560,490 0,490 0,0  - works
_SELECT 280,0 560,245 JOIN

 

.....join all

 

....filled in every corner R5

 

.....insert a text in the middle of the square

 

Couldnt find anything on google, that really helped

Posted

not really a script but should get you what you need.

 

Pick the midpoint of the rectangle

creates points LL and UR

creates rectangle from points.

changes fillet radius to 5

fillets rectangle

adds text to middle of rectangle

 

run lisp by either typing TXTREC or TR

 

;;----------------------------------------------------------------------;;
;; CREATE RECTANGLE W\ TEXT IN MIDDLE
(defun C:TXTREC (/ MPT LL UR)
  (setq MPT (getpoint "\nPick Midpoint")
        LL (mapcar '- MPT '(280 245 0)) ;change the values here to 1/2 the length and width of rectangle you want
        UR (mapcar '+ MPT '(280 245 0)) ;change the values here to 1/2 the length and width of rectangle you want
  )
  (command "_.Rectangle" LL UR)
  (setvar 'filletrad 5)                 ;change to the fillet radius you want
  (command "_.Fillet" "P" (entlast))
  (entmake 
    (list 
      '(0 . "TEXT")
      (cons 10  MPT)
      (cons 11  MPT)
      (cons 40 (getvar 'DIMTXT))
      (cons 1  "text you want here")
      '(72 . 4)
    )
  )
)
(defun C:TR () (C:TXTREC))

 

Posted (edited)

Maybe 

 

(defun C:TXTREC (/ MPT LL UR L H rad)
  (setq MPT (getpoint "\nPick Midpoint")
        L (getreal "\Enter length ")
        H (getreal "\nEnter height ")
	rad (getreal "\nEnter radius ")
        LL (mapcar '- MPT (list (/ L 2.0) (/ H 2.0) 0))
        UR (mapcar '+ MPT (list (/ L 2.0) (/ H 2.0) 0))
  )
  (command "_.Rectangle" LL UR)
  (setvar 'filletrad rad)                 ;change to the fillet radius you want
  (command "_.Fillet" "P" (entlast))
  (entmake 
    (list 
      '(0 . "TEXT")
      (cons 10  MPT)
      (cons 11  MPT)
      (cons 40 (getvar 'DIMTXT))
      (cons 1  "text you want here")
      '(72 . 4)
    )
  )
)
(defun C:TR () (C:TXTREC))

I would use multi getvals.lsp

 

Screenshot420.png

Edited by BIGAL
  • Agree 1
Posted

Use the rectangle command as suggested which is quicker than drawing lines and then joining them, the fillet command also has various options available for using in an LT script.

Try running the command and watch the command line which prompts you for input. So in your case you want to start the fillet command and the use the 'radius op[tion (which only needs the letter 'r' in a script followed by the radius you want, you are then prompted again for input and you see an option to select a polyline using the command modifier 'L' will select the last object created and then enter to accept the selection (enter is carried out by using a space or empty line in your script).

When you then start the mtext command you can again use command modifiers to select the geometric center of the last object created. The mtext command in a script allows for various options if you watch the command line for the prompts

  • Like 2

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