Jump to content

lisp to draw pline


bbryson_2000

Recommended Posts

(defun c:mypline ( / plw )
   (setq plw (getvar 'plinewid))
   (setvar 'plinewid 0.03125)
   (vl-cmdf "_.pline")
   (while (= 1 (logand 1 (getvar 'cmdactive))) (vl-cmdf "\\"))
   (setvar 'plinewid plw)
   (princ)
)

Link to comment
Share on other sites

Simple and to the point as usual Lee a thought referring to the error trapping reactor posted previously by me, the user would type p132 on command line ie pline 1/32 wide p18 1/8 so no hard coding of width. Watch this space.

Link to comment
Share on other sites

Have a go at this you will need to do P0-03125 for a 1/32 width 2nd version could do p132

 

; Enter the filet radius as part of a command line entry f100, offset O234, circle c123-45, P123 for pline width
; note - is used for decimal point
; original code and methology by Alan H
; assistance and code that worked by Lee-Mac
; OCT 2015

(   (lambda nil
       (vl-load-com)
       (foreach obj (cdar (vlr-reactors :vlr-command-reactor))
           (if (= "fillet-reactor" (vlr-data obj))
               (vlr-remove obj)
           )
       )
       (vlr-command-reactor "fillet-reactor" '((:vlr-unknowncommand . fillet-reactor-callback)))
   )
)

(defun plwid ( / width oldwidth)
(setq width (distof (substr com 2) 2))
           (setq oldwidth (getvar 'plinewid))
           (if (<= 0.0 width)
             (progn
      (setvar 'plinewid width )
             (vla-sendcommand fillet-reactor-acdoc "_.pline ")
             (setvar 'plinewid oldwidth)
             )
           ) 
)
(defun filletrad ( / rad)
(setq rad (distof (substr com 2) 2))
           (if (<= 0.0 rad)
             (progn        
             (setvar 'filletrad rad)
             (vla-sendcommand fillet-reactor-acdoc "_.fillet ")
             )
             ) 
)
(defun makecirc ( / rad)
(setq rad (distof (substr com 2) 2))
           (if (<= 0.0 rad)
           (progn        
           (setvar 'circlerad rad)
           (vla-sendcommand fillet-reactor-acdoc "_.Circle ")
           )
           )
)
(defun offdist ( / dist)
(setq dist (distof (substr com 2) 2))
           (if (<= 0.0 dist)
           (progn        
           (setvar 'offsetdist dist)
           (vla-sendcommand fillet-reactor-acdoc "_.Offset  ")
           )
           )
)

(defun fillet-reactor-callback ( obj com )
(setq com (vl-string-translate "-" "." (strcase (car com))))
   (cond   
       (   (and
           (wcmatch com "~*[~F.0-9]*")
           (wcmatch com "F*")
           (wcmatch com "~F*F*")
           (wcmatch com "~*.*.*")
           ) ; and
           (filletrad) 
        ) 

        (  (and
           (wcmatch com "~*[~C.0-9]*")
           (wcmatch com "C*")
           (wcmatch com "~C*C*")
           (wcmatch com "~*.*.*")
           ) ;and
           (makecirc) 
        )

        (  (and
           (wcmatch com "~*[~O.0-9]*")
           (wcmatch com "O*")
           (wcmatch com "~O*O*")
           (wcmatch com "~*.*.*")
           ) ; and
           (offdist) 
        )

        (  (and
           (wcmatch com "~*[~P.0-9]*")
           (wcmatch com "P*")
           (wcmatch com "~P*P*")
           (wcmatch com "~*.*.*")
           ) ; and
           (plwid) 
        )

   ) ; master cond
) ; defun

(princ)

(or fillet-reactor-acdoc
   (setq fillet-reactor-acdoc (vla-get-activedocument (vlax-get-acad-object)))
)
(princ)

; next Point or option keyword required.

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