cut layer to 1m to the next layer

cut layer to 1m to the next layer

Fleww
Advocate Advocate
588 Views
3 Replies
Message 1 of 4

cut layer to 1m to the next layer

Fleww
Advocate
Advocate

orginal version.png

final stage.png

cut like this red.png

Hi, can you please help me, I need lisp to cut layer Garden Trench(green one) to the layer Trench(blue one), to make it to the final look like red one - 1m lenght from the layer Trench. Its big drawings so its so annoying to do it manual. Please help

0 Likes
Accepted solutions (1)
589 Views
3 Replies
Replies (3)
Message 2 of 4

ВeekeeCZ
Consultant
Consultant
Accepted solution

You can use this routine for multiple LENGTHEN. Start/Total/1

Then remove the un-touching rest. It should not take that long.

 

(vl-load-com)
(defun c:LengthenAdvanced ( / *error osm* s i e l f) ; Specifice od ktereho konce nebo středu
  
  (defun *error* (errmsg)
    (if (not (wcmatch errmsg "Function cancelled,quit / exit abort,console break,end"))
      (princ (strcat "\nError: " errmsg)))
    (if osm (setvar 'OSMODE osm))
    (princ))
  
  (if (and (setq s (ssget "_:L" '((0 . "LINE,LWPOLYLINE,ARC"))))
	   (setq osm (getvar 'osmode))
	   (setvar 'osmode 0)
	   
	   (or *la-opt1* (setq *la-opt1* "Middle"))
	   (not (initget "Start Middle End"))
	   (setq *la-opt1* (cond ((getkword (strcat "\nApply changes from [Start/Middle/End] <" *la-opt1* ">: ")))
				 (*la-opt1*)))
	   
	   (or *la-opt2* (setq *la-opt2* "Total"))
	   (not (initget "Delta Percent Total"))
	   (setq *la-opt2* (cond ((getkword (strcat "\nSpecify type of change [Delta/Percent/Total] <" *la-opt2* ">: ")))
				 (*la-opt2*)))
	   (cond ((= *la-opt2* "Delta")
		  (or *la-delta* (setq *la-delta* 1.))
		  (setq *la-delta* (cond ((getdist (strcat "\nEnter delta length <" (rtos *la-delta*) ">: ")))
					 (*la-delta*))))
		 ((= *la-opt2* "Percent")
		  (or *la-percent* (setq *la-percent* 100.))
		  (setq *la-percent* (cond ((getreal (strcat "\nEnter percentage length <" (rtos *la-percent*) ">: ")))
					   (*la-percent*))))
		 
		 ((= *la-opt2* "Total")
		  (or *la-total* (setq *la-total* 1.))
		  (setq *la-total* (cond ((getdist (strcat "\nSpecify total length <" (rtos *la-total*) ">: ")))
					 (*la-total*)))))
	   )
    (if (/= *la-opt1* "Middle")
      
      (progn
	(cond ((= *la-opt2* "Delta")	(command "_.lengthen" "_delta" *la-delta*))
	      ((= *la-opt2* "Percent")	(command "_.lengthen" "_percent" *la-percent*))
	      ((= *la-opt2* "Total")	(command "_.lengthen" "_total" *la-total*)))
	(repeat (setq i (sslength s))
	  (setq e (ssname s (setq i (1- i))))
	  (cond ((= *la-opt1* "Start")	(command (list e (vlax-curve-getpointatparam e (vlax-curve-getstartparam e)))))
		((= *la-opt1* "End")	(command (list e (vlax-curve-getpointatparam e (vlax-curve-getendparam e)))))))
	(if (> (getvar 'cmdactive) 0) (command "")))
      
      (if (= *la-opt2* "Delta")
	(progn
	  (command "_.lengthen" "_delta" (/ *la-delta* 2))
	  (repeat (setq i (sslength s))
	    (setq e (ssname s (setq i (1- i))))
	    (command (list e (vlax-curve-getpointatparam e (vlax-curve-getstartparam e)))
		     (list e (vlax-curve-getpointatparam e (vlax-curve-getendparam e)))))
	  (if (> (getvar 'cmdactive) 0) (command "")))
	
	(repeat (setq i (sslength s))   ;; Middle Percent and Total
	  (setq e (ssname s (setq i (1- i)))
		l (vlax-curve-getdistatparam e (vlax-curve-getendparam e))
		f (if (= *la-opt2* "Percent") (* l *la-percent* 0.01) *la-total*))
	  (command "_.lengthen" "_delta" (/ (- f l) 2)
		   (list e (vlax-curve-getpointatparam e (vlax-curve-getstartparam e)))
		   (list e (vlax-curve-getpointatparam e (vlax-curve-getendparam e)))
		   "")))))
  (*error* "end")
  )

 

Message 3 of 4

Fleww
Advocate
Advocate

Thank you so much! ❤️ perfect

 

0 Likes
Message 4 of 4

Sea-Haven
Mentor
Mentor

Not sure image not zoomed in you want a 1m red line at end of green line, ie my way maybe trim green lines by offsetting blue 1m using ssget "F" can trim out all the green lines, at same time remember all green line end points 1st so just after trim add a red line. Maybe easier method.

0 Likes