LISP that would redraw sample lines with polylines.

LISP that would redraw sample lines with polylines.

ca20
Explorer Explorer
792 Views
2 Replies
Message 1 of 3

LISP that would redraw sample lines with polylines.

ca20
Explorer
Explorer

Hello,

 

Could You please help me with lisp that would allow me to export sample lines with their station values by:

 

- redrawig all existing sample lines (AECC_SAMPLE_LINE) with either lines or polylines;

 

- adding value of every sample lines „Station” property to corresponding polylinesThickness” property;

 

- adding wordSampleLine” to each polyline „Hyperlink” property;

 

That’s because „Thickness” and „Hyperlink” properties are easily accessible through MAPEXPORT command for lines / polylines, so I could rename them during export and continue to work with such .shp in different apps. I wasn’t able to find any workaround to export Sample Lines with their „Stations”, and this is complicating my workflow a lot, so any help would be much appreciated.

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

Jeff_M
Consultant
Consultant
Accepted solution

This lisp should do the trick. Polylines are created on the current layer. Load the lisp, run the command SAMPLES2POLYS, select a sample line in the group to process, done.

 

(defun c:samples2polys (/ doc ms obj grp verts polyverts pline)
  (if (setq ss (ssget":S" '((0 . "AECC_SAMPLE_LINE"))))
    (progn
      (setq doc (vla-get-activedocument (vlax-get-acad-object)))
      (setq ms (vla-get-modelspace doc))
      (setq obj (vlax-ename->vla-object (ssname ss 0)))
      (setq grp (vlax-get obj 'parent))
      (setq idx -1)
      (vlax-for sl (vlax-get grp 'samplelines)
	(setq verts (vlax-get sl 'vertices))
	(setq polyverts '())
	(vlax-for v verts
	  (setq x (vlax-get v 'location))
	  (setq polyverts (append polyverts (list (car x) (cadr x))))
	  )
	(setq pline (vlax-invoke ms 'addlightweightpolyline polyverts))
	(vla-put-thickness pline (vlax-get sl 'station))
	(vla-add (vla-get-hyperlinks pline) "Sample Line")
	)
      )
    )
  (princ)
  )
Jeff_M, also a frequent Swamper
EESignature
Message 3 of 3

ca20
Explorer
Explorer
This code does exactly what it was supposed to, and fits perfectly into my workflow. Thank You so much Jeff, You just saved hours of my work.
0 Likes