Author Topic: fillet at two intersecting lines  (Read 3968 times)

0 Members and 1 Guest are viewing this topic.

ELOQUINTET

  • Guest
fillet at two intersecting lines
« on: December 05, 2003, 09:15:31 AM »
hey guys it's been kinda quiet in here lately so i figured i'd give you a little challenge. i have this lisp which works great but i only use one of the options. it is an enhanced fillet and the only options i use is the intersection. i would like to modify it so i can type in mf or maybe fi would be more fitting and it will ask me to select intersection and will fillet the two. also would it be possible to add radius to this as well that would be most excellent. party on wayne...

dan

oh yeah the code:

;;Tip1872      MF.LSP    ENHANCED FILLET COMMAND      (c) 2003 Sanjay Kulkarnisan
;Sanjay Kulkarnisan


;;;;; The code starts
(defun c:mFillet (/ ftMode)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;                                                      ;;;
;;; Function Name  : mFillet                             ;;;
;;;                                                      ;;;
;;; Description    : 1) Fillet command with a new option ;;;
;;;                  to fillet two lines by selecting    ;;;
;;;                  only the intersection point.        ;;;
;;;                  2) The fillet command continues     ;;;
;;;                  after the radius option.            ;;;
;;;                                                      ;;;
;;; Argument       : None.                               ;;;
;;;                                                      ;;;
;;; Returned value : None.                               ;;;
;;;                                                      ;;;
;;; Usage          :  mFillet / (c:mFillet) / mf / (c:mf);;;
;;;                                                      ;;;
;;; Dependancies   :  calls mfExec                       ;;;
;;;                                                      ;;;
;;; Global Vars    :  oCMDECHO, oCMDECHO                 ;;;
;;;                                                      ;;;
;;; Date:  26/04/02.                                     ;;;
;;;                                                      ;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;                                                      ;;;
;;; NOTE: NO COMPREHENSIVE DATA VALIDATION OR ERROR      ;;;
;;;       HANDLING INCORPORATED.                         ;;;
;;;                                                      ;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;                                                      ;;;
;;; Variables List:                                      ;;;
;;;                                                      ;;;
;;; oCMDECHO : existing value of cmdecho sysvar.         ;;;
;;; oCMDECHO : existing value of dimzin sysvar.          ;;;
;;; ftMode   : existing fillet trim mode (string).       ;;;
;;;                                                      ;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  (setq oCMDECHO (getvar "cmdecho"))
  (setvar "cmdecho" 0)
  (setq oDIMZIN (getvar "dimzin"))
  (setvar "dimzin" 0)
  (if (= (getvar "trimmode") 0)
    (setq ftMode "NOTRIM")
    (setq ftMode "TRIM")
  )
  (prompt (strcat "MFILLET\nCurrent settings: Mode = "
        ftMode
        ", Radius = "
        (rtos   (getvar "filletrad")
         2
         (getvar "luprec")
        )
     )
  )
  (mfExec)
  (setvar "dimzin" oDIMZIN)
  (setvar "cmdecho" oCMDECHO)
  (princ)
)
(defun mfExec
       (/ mfPrmpt resp ss1 rPrmpt fRad ftMode tPrmpt pt intLines)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;                                                      ;;;
;;; Function Name  : mfExec                              ;;;
;;;                                                      ;;;
;;; Description    : Fillet command with a new option    ;;;
;;;                  do fillet two lines by selecting    ;;;
;;;                  only the intersection point.        ;;;
;;;                                                      ;;;
;;; Argument       : None.                               ;;;
;;;                                                      ;;;
;;; Returned value : None.                               ;;;
;;;                                                      ;;;
;;; Usage          :  (mfExec)                           ;;;
;;;                                                      ;;;
;;; Dependancies   :  called by mFillet                  ;;;
;;;                                                      ;;;
;;; Global Vars    :  oCMDECHO, oCMDECHO                 ;;;
;;;                                                      ;;;
;;; Date:  26/04/02.                                     ;;;
;;;                                                      ;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;                                                      ;;;
;;; NOTE: NO COMPREHENSIVE DATA VALIDATION OR ERROR      ;;;
;;;       HANDLING INCORPORATED.                         ;;;
;;;                                                      ;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;                                                      ;;;
;;; Variables List:                                      ;;;
;;;                                                      ;;;
;;; mfPrmpt  : command prompt                            ;;;
;;; resp     : response to the command promptar.         ;;;
;;; rPrmpt   : prompt at the r option                    ;;;
;;; fRad     : fillet radius                             ;;;
;;; ftMode   : fillet trim mode                          ;;;
;;; tPrmpt   : prompt at the t option                    ;;;
;;; oCMDECHO : existing value of cmdecho sysvar.         ;;;
;;; oCMDECHO : existing value of dimzin sysvar.          ;;;
;;; ss1      : sSet of lines passing thro' clicked pt.   ;;;
;;; pt       : the point clicked (intersection)          ;;;
;;; intLines : no. of intersecting lines                 ;;;
;;;                                                      ;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  (setq   mfPrmpt
   "\nSelect first object or [Intersection (of 2 lines)/Polyline/Radius/Trim]: "
  )
  (while (= resp nil)
    (initget "Intersection Polyline Radius Trim")
    (setq resp (entsel mfPrmpt))
  )
  (cond
    ((= resp "Polyline")
     (progn
       (vl-cmdf "Fillet" "P")
       (princ)
     )
    )
    ((= resp "Radius")
     (progn
       (setq rPrmpt (strcat "Specify fillet radius <"
             (rtos (getvar "filletrad"))
             "> : "
          )
       )
       (setq fRad (getdist rPrmpt))
       (vl-cmdf "fillet" "r" fRad)
       (mfExec)
     )
    )
    ((= resp "Trim")
     (progn
       (if (= (getvar "trimmode") 0)
   (setq ftMode "No trim")
   (setq ftMode "Trim")
       )
       (setq
   tPrmpt   (strcat   "\nEnter Trim mode option [Trim/No trim] <"
         ftMode
         ">: "
      )
       )
       (initget "Trim Notrim")
       (setq ftMode (getkword tPrmpt))
       (vl-cmdf "fillet" "T" ftMode "")
       (mfExec)
     )
    )
    ((= resp "Intersection")
     (progn
       (setq oOSMODE (getvar "osmode"))
       (setvar "osmode" 32)
       (while (= ss1 nil)
   (setq
      pt (getpoint "\nClick intersection of two lines only : ")
   )
   (setq ss1 (ssget "c" pt pt))
       )
       ;; While ss1 nil
       (setq intLines (sslength ss1))
       (while (or (/= intLines 2)
        (/= (cdr (assoc 0 (entget (ssname ss1 0)))) "LINE")
        (/= (cdr (assoc 0 (entget (ssname ss1 1)))) "LINE")
         )
   ;; Or
   (if (\= intLines 2)
      (progn
        (setq errPrmpt (strcat "\nAt this point " (itoa intLines)))
        (setq errPrmpt (strcat errPrmpt " lines intersect."))
        (setq errPrmpt (strcat errPrmpt
                "\nThis option, unfortunately,"
             )
        )
        (setq
          errPrmpt   (strcat errPrmpt " works only when exactly")
        )
        (setq errPrmpt (strcat errPrmpt " two lines intersect."))
        (alert errPrmpt)
      )
   )
   (setq pt
      (getpoint
        "\nSelection Error!!\nClick intersection of two lines only: "
      )
   )
   (setq ss1 (ssget "c" pt pt))
   (setq intlines (sslength ss1))
       )
       (setvar "osmode" 0)
       (vl-cmdf "fillet" (ssname ss1 0) (ssname ss1 1))
       (setq ss1 nil)
       (setvar "osmode" oOSMODE)
     )
    )
    (progn
     (vl-cmdf "fillet" (car resp))
    )
  )
)
(defun c:mf ()
  (c:mfillet)
)
(vl-load-com)

ELOQUINTET

  • Guest
fillet at two intersecting lines
« Reply #1 on: December 05, 2003, 12:08:25 PM »
whoops i read that a second time and saw something. when i say add radius i don't mean the existing radius option. i mean you could select the intersection and be prompted for radius similar to the regular fillet with 0 being the default. thanks

dan