Author Topic: Autolisp Trim on One Side of Polyline  (Read 1842 times)

0 Members and 1 Guest are viewing this topic.

mailmaverick

  • Bull Frog
  • Posts: 494
Autolisp Trim on One Side of Polyline
« on: June 27, 2017, 04:01:20 AM »
Hi

I want to trim multiple polylines by a specified distance (5.0) from start. I have made following routine :-
Code: [Select]
(defun c:test ()
  (vl-load-com)
  (setq dist 5.0)
  (setq ent (car (entsel "\nSelect object to trim:"))
obj (vlax-ename->vla-object ent)
lyr (vla-get-layer obj)
pt (vlax-curve-getPointAtDist obj dist)
tp1 (vlax-curve-getPointAtDist obj (+ dist 0.01))
tp2 (vlax-curve-getPointAtDist obj (- dist 0.01))
ang (angle tp2 tp1)
piby2 (/ pi 2.0)
tp3 (polar pt (+ ang piby2) 0.1)
tp4 (polar pt (- ang piby2) 0.1)
linent (entmakex
  (list (cons 0 "LINE") (cons 8 lyr) (cons 10 tp3) (cons 11 tp4) (cons 210 (list 0.0 0.0 1.0)))
)
  )
  (command "TRIM" linent "" ent "")
  (entdel linent)
  (princ)
)

The above code works fine in trimming the lines. But the problem is that on certain lines, it trims the starting (5.0) which is my requirement but for some lines it trims the remaining line. How to always trim the starting 5.0 length only ?
Note : I cannot use Express Tool EXTRIM

ribarm

  • Gator
  • Posts: 3225
  • Marko Ribar, architect
Re: Autolisp Trim on One Side of Polyline
« Reply #1 on: June 27, 2017, 04:21:08 AM »
I think you need to specify start point of polyline somewhere inside TRIM command... Some other approach would be using LENGTHEN command, but you'll have to experiment with that too...
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube