Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Double offset and trim multiple lines Lisp

3 REPLIES 3
Reply
Message 1 of 4
wbult
2917 Views, 3 Replies

Double offset and trim multiple lines Lisp

Need help looking for a Lisp.  Situation is, I download GIS road centerlines, which are poly lines. Then offset the road centerline to each side and then trim at the intersections.  Want a lisp where I enter the offset to each side, then allow me to select multiple lines, and trim lines that intersect.  Have found simple one that I have to select each line individually and trim manually,  Looking for something to speed it up.

 

Thanks

3 REPLIES 3
Message 2 of 4
Hallex
in reply to: wbult

Try this code to speed up, not sure about how it will be work on your release

(defun C:geof (/ *error* acsp adoc clon  clon1 clon2 delobjs fcode fdata fuzz gap  pfs pline_objs ssunion1 ssunion2 un1lst un2lst x)
;; fixo  2014
(vl-load-com)
  (defun *error* (msg)
(vla-endundomark (vla-get-activedocument (vlax-get-acad-object)))
(if (> (length delobjs) 0)
    (progn
    (foreach obj delobjs
      (vl-catch-all-apply 'vla-delete (list obj)))))

(princ)
)
  (setq adoc (vla-get-activedocument (vlax-get-acad-object))
	acsp (vla-get-block (vla-get-activelayout adoc)))
  (setq pfs (vla-get-pickfirstselectionset adoc) )
  (vla-startundomark (vla-get-activedocument (vlax-get-acad-object)))
(prompt "\nSelect centerlines: ")
 ;; clean up selection
(vl-catch-all-apply 'vla-clear (list pfs))
;; add desired layer name to filter exclusively centerlines, optional
 (setq fcode   (vlax-safearray-fill
		 (vlax-make-safearray vlax-vbinteger '(0 . 6))
		 (list -4 -4 0 70 -4 410 -4)
		 )      
    fdata  (vlax-safearray-fill
	     (vlax-make-safearray vlax-vbvariant '(0 . 6))
	     (list "<and" "<and" "lwpolyline" 0 "and>" (getvar "ctab") "and>"))
       )
(vla-selectonscreen pfs  fcode fdata)

(if (> (vla-get-count pfs) 0)
(progn

  
   (initget 6)
      (setq gap (getdist "\nWhole road width: "))
      (setq fuzz (* 0.025 gap)); increment peditgap to suit
      (setq gap (/ gap 2))
  
  
  (vlax-for obj pfs
    (setq clon (vl-catch-all-apply 'vla-copy (list obj )))
(vl-catch-all-apply 'vla-put-color (list clon 1))
    (setq delobjs (cons clon delobjs)))

  (foreach obj delobjs

  (setq clon1 (car (vlax-safearray->list (vlax-variant-value(vla-offset obj gap)))))
    (vl-catch-all-apply 'vla-put-layer (list clon1 "0"))
    (vl-catch-all-apply 'vla-put-linetype (list clon1 "Continuous"))
    (vl-catch-all-apply 'vla-put-color (list clon1 1))

  (setq un1lst (cons clon1 un1lst))
    
  (setq clon2 (car (vlax-safearray->list (vlax-variant-value(vla-offset obj (* -1 gap))))))
    (vl-catch-all-apply 'vla-put-layer (list clon2 "0"))
    (vl-catch-all-apply 'vla-put-linetype (list clon2 "Continuous"))
    (vl-catch-all-apply 'vla-put-color (list clon1 1))

  (setq un2lst (cons clon2 un2lst))

)
 
(setq ssunion1 (ssadd))

(mapcar '(lambda (x)(ssadd x ssunion1))(mapcar 'vlax-vla-object->ename un1lst))
  ;(initcommandversion)
  (vl-cmdf "_.pedit" "_M" ssunion1 "" "_J" fuzz "")
  (princ "\nproc 3")
(setq ssunion2 (ssadd))
(mapcar '(lambda (x)(ssadd x ssunion2))(mapcar 'vlax-vla-object->ename un2lst))
;(initcommandversion)
(vl-cmdf "_.pedit" "_M" ssunion2 "" "_J" fuzz "")

    ;; clean up memory

  (if (> (length delobjs) 0)
    (progn
    (foreach obj delobjs
      (vl-catch-all-apply 'vla-delete (list obj)))))
  (vla-regen adoc acActiveViewport)

  (princ "\nCommand end\n")
  )
  )
  (princ)
  )

 

_____________________________________
C6309D9E0751D165D0934D0621DFF27919
Message 3 of 4
wbult
in reply to: wbult

Gave it a try, but didn't work.  Working on AutoCAD Civil 3D 2014.  Thanks for trying to help out.

 

Message 4 of 4
Hallex
in reply to: wbult

I think you have do following

Add this lisp from attachment in TrustedPaths folder, see in Options->Files tab etc

Then use Appload and add this file in Contenst-> Start up

Reload Acad then try again, just tested it in A2014 on my end,

all is working good for me (although I've used russian settings on

my Windows 7)

_____________________________________
C6309D9E0751D165D0934D0621DFF27919

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost