Author Topic: (code) quick trim  (Read 2983 times)

0 Members and 1 Guest are viewing this topic.

Mark

  • Custom Title
  • Seagull
  • Posts: 28762
(code) quick trim
« on: January 08, 2004, 09:22:35 AM »
Code: [Select]
;;; quick trim
;;; allows you to draw a line as a cutting edge
;;; then erases the line when done trimming
(defun c:qt (/ p1 ent)
  (cond ((vl-cmdf "_.line"
 (setq p1 (getpoint "\nSelect First Point: "))
 (getpoint p1 "\nSelect Second Point: ")
 ""
 )
(setq ent (entlast))
(command "_.trim" ent "")
(while (> (getvar 'cmdactive) 0) (command pause))
(command "_.erase" ent "")
)
)
  )
TheSwamp.org  (serving the CAD community since 2003)

qjchen

  • Bull Frog
  • Posts: 285
  • Best wishes to all
Re: (code) quick trim
« Reply #1 on: May 31, 2006, 04:48:12 AM »
Dear Thomas
I like your command, and because some time the trimed line is in mass,
so I modify your code and as follows, I hope you dont mind.
Code: [Select]
;;; Author: Mark Thomas                       
;;; Function: Quick trim                       
;;; Allows you to draw a line as a cutting edge
;;; then erases the line when done trimming   
;;; Modify:Q.J.Chen                           
 
(defun c:qt (/ p1 ent p2 p3 p4 p5 ent op obj ang sset a)
  (command "undo" "be")
  (setq a (getvar "osmode"))
  (setvar "osmode" 0)
  (cond
    ((vl-cmdf "_.line" (setq p1 (getpoint "\nSelect First Point: "))
      (setq p2 (getpoint p1 "\nSelect Second Point: "))
      ""
     )
      (setq ent (entlast))
      (setq p3 (getpoint "\nWhich sides: "))
      (setq obj (vlax-ename->vla-object ent))
      (setq op (vlax-curve-getclosestpointto obj p3))
      (setq ang (angle op p3))
      (setq p4 (polar p1 ang 1))
      (setq p5 (polar p2 ang 1))
      (setq sset (ssget "_f" (list p1 p2)))
      (command "_.trim" sset "" "f" p4 p5 "" "")
      (command "_.erase" ent "")
    )
  )
  (setvar "osmode" a)
  (command "undo" "e")
)

The effect is as follow

but I feel trouble about the number 1 in (setq p4 (polar p1 ang 1)),
I think it should be a very little number, like 0.01 or less,
but when I change it to 0.01, many line cant be trimed.
Is it the wrong of "f" selection method?
http://qjchen.mjtd.com
My blog http://chenqj.blogspot.com (Chinese, can be translate into English)