Author Topic: request for help to edit a lisp  (Read 2094 times)

0 Members and 1 Guest are viewing this topic.

jtm2020hyo

  • Newt
  • Posts: 198
request for help to edit a lisp
« on: April 25, 2020, 03:56:27 PM »
Code: [Select]
;;; Helper function to get the point from pt1 perp to entity picked at point pt2
(defun GetPerpPoint (pt1 pt2 /)
  (setvar "LASTPOINT" pt1)
  (osnap pt2 "_perp")
) ;_ end of defun

;;; Helper function to get the distance from pt1 perp to entity picked at point pt2
(defun GetPerpDist (pt1 pt2 /)
  (distance pt1 (GetPerpPoint pt1 pt2))
) ;_ end of defun

(setq MFillet:Inc "No") ;Remember increment fillet

;;; Fillet multiple lines by selecting with fences
(defun c:MFillet_lines (/ ss1 ss2 n m en1 en2 pt1 pt2 ptlast rad rad1 cmd)
  (setq cmd (getvar "CMDECHO")) ;Get value of CMDECHO
  (setvar "CMDECHO" 0) ;Don't show prompts on command line
  (command "_.UNDO" "_BEgin")
  (setq rad (getvar "FILLETRAD")) ;Get the normal fillet radius
  (while (/= (type pt1) 'List)
    (princ (strcat "\nCurrent settings: Raduis = "
                   (rtos rad)
                   ", Increment Fillet = "
                   MFillet:Inc
                   "\n"
           ) ;_ end of strcat
    ) ;_ end of princ
    (initget "Radius Increment") ;Setup for keywords
    (setq pt1 (getpoint "Select by fence-line 1st set of entities [Radius/Increment]: ")) ;Get 1st point
    (cond
      ((and (= pt1 "Radius")
            (setq rad1 (getDist (strcat "New Radius <" (rtos rad) ">: ")))
       ) ;_ end of and
       (setq rad rad1)
      )
      ((= pt1 "Increment")
       (initget "Yes No")
       (if (setq rad1 (getkword (strcat "Do you want to increment the radius? [Yes/No] <" MFillet:Inc ">: ")))
         (setq MFillet:Inc rad1)
       ) ;_ end of if
      )
    ) ;_ end of cond
  ) ;_ end of while
  (setq pt2 (getpoint pt1 "2nd point of fence-line: ")
        ss1 (ssget "F" (list pt1 pt2))
  ) ;_ end of setq
  (setq pt1 (getpoint "Select by fence-line 2nd set of entities: ")
        pt2 (getpoint pt1 "2nd point of fence-line: ")
        ss2 (ssget "F" (list pt1 pt2))
  ) ;_ end of setq
  (setq n    0
        m    0
        rad1 0.0 ;Initialize the radius to add
  ) ;_ end of setq
  (while (and ss1 ss2 (< n (sslength ss1)) (< m (sslength ss2)))
    (setq en1 (ssname ss1 n)
          pt1 (cadr (cadddr (car (ssnamex ss1 n))))
          en2 (ssname ss2 m)
          pt2 (cadr (cadddr (car (ssnamex ss2 m))))
    ) ;_ end of setq
    (if (and ptlast (= MFillet:Inc "Yes"))
      (setq rad1 (+ rad1 (GetPerpDist ptlast pt1)))
    ) ;_ end of if
    (setvar "FILLETRAD" (+ rad rad1))
    (command "_.FILLET" (list en1 pt1) (list en2 pt2))
    (setq n (1+ n)
          m (1+ m)
          ptlast pt1
    ) ;_ end of setq
  ) ;_ end of while
  (setvar "FILLETRAD" rad) ;Restore previous radius
  (command "_.UNDO" "_End")
  (setvar "CMDECHO" cmd) ;Restore prompts on command line
  (princ)
) ;_ end of defun

the code fillet multiple lines to lines, polylines to lines, but not polylines to polylines. Someone might edit the lisp to allow fillet multiple polylines?, and if possible explain us as was solved?

jtm2020hyo

  • Newt
  • Posts: 198
Re: request for help to edit a lisp
« Reply #1 on: April 26, 2020, 03:20:51 AM »
sorry for double post.

I have another lisp for fillet multiple lines

Code: [Select]
(defun c:mfillet_int (/ pt1 pt2 pt3 pt4 obj1 obj2 lst1 lst2 lst dist1 dist2 x ss ss2)

  (setq pt1 (getpoint "Pick outside"))
  (setq pt2 (getpoint pt1 "Pick inside"))
  (setq pt3 (getpoint pt2 "Pick outside"))

  (setq lst (list pt1 pt2))
  (setq ss (ssget "F" lst (list (cons 0 "*line"))))

  (setq lst (list pt2 pt3))
  (setq ss2 (ssget "F" lst (list (cons 0 "*line"))))

  (if (= (sslength ss) (sslength ss2))
    (progn
      (command "line" pt1 pt2 "")
      (setq obj1 (vlax-ename->vla-object (entlast)))
      (command "Line" Pt2 pt3 "")
      (setq obj2 (vlax-ename->vla-object (entlast)))

      (setq lst1 '())
      (repeat (setq x (sslength ss))
        (setq obj (vlax-ename->vla-object (ssname ss (setq x (- x 1)))))
        (setq pt4 (vlax-invoke obj1 'intersectWith obj acExtendThisEntity))
        (setq dist1 (distance pt2 pt4))
        (setq lst1 (cons (list dist1 pt4) lst1))
      )
      (setq lst1 (vl-sort lst1
                          (function (lambda (e1 e2)
                                            (< (car e1) (car e2))
                                    )
                          )
                 )
      )

      (setq lst2 '())
      (repeat (setq x (sslength ss2))
        (setq obj (vlax-ename->vla-object (ssname ss2 (setq x (- x 1)))))
        (setq pt4 (vlax-invoke obj2 'intersectWith obj acExtendThisEntity))
        (setq dist1 (distance pt2 pt4))
        (setq lst2 (cons (list dist1 pt4) lst2))
      )
      (setq lst2 (vl-sort lst2
                          (function (lambda (e1 e2)
                                            (< (car e1) (car e2))
                                    )
                          )
                 )
      )

      (vla-delete obj1)
      (vla-delete obj2)

      (Setq choice (getstring "\n Press Enter for In any key for out"))

      (if (= choice "") (setq lst1 (reverse lst1)))
      (setvar 'filletrad 0.0)
      (setq x 0)
      (repeat (sslength ss)
        (setq pt1 (cadr (nth x lst1)))
        (setq pt2 (cadr (nth x lst2)))
        (command "._FILLET" pt1 pt2)
        (setq x (+ x 1))
      )
    )

  )
  (princ)
)

this lisp works with lines to lines and polylines to polylines, but not lines to polylines and polylines to lines, but the first lisp can merge polylines and lines.

I am trying to merge the best of both lisp but no luck. Might someone help me?

MickD

  • King Gator
  • Posts: 3636
  • (x-in)->[process]->(y-out) ... simples!
Re: request for help to edit a lisp
« Reply #2 on: April 26, 2020, 06:50:57 AM »
Can you show the code you have written so far to try and solve the problem ??
"Programming is really just the mundane aspect of expressing a solution to a problem."
- John Carmack

"Short cuts make long delays,' argued Pippin.”
- J.R.R. Tolkien

jtm2020hyo

  • Newt
  • Posts: 198
Re: request for help to edit a lisp
« Reply #3 on: April 27, 2020, 09:08:53 AM »
attached lisp. 90% already problem was already solved.

the unique problem now is when I try fillet multiple *lines but they all are very close.

in the image i need to fillet 100 lines with 100 polylines. but a error happends.





but a error happends.



To solve this I need to do zoom and use the lisp for reduced numbers of selected *lines.

might you help me? maybe add a code to do automatically zoom in each intersection?