TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: rugaroo on October 08, 2003, 03:37:39 PM
-
Do you guys know if there is a program besides divide that will divide an entity such as pline, line, or arc into specified increments from a given point? Hope that is clear enough.
Rug
-
Specified increments? Yes, MEASURE :D
DIVIDE does not specify increments but number of parts.
-
Rug, if you're interested in creating your own measurement functions then you might wanna take a look at the VLAX-CURVE-thingies.
Below are two functions that can perhaps get you started.
MeasureCurve does the same as MEASURE - without ability to insert blocks at measurements, of course. It takes any curve object (notice it's a VLA-OBJECT) and sets out points at the distances.
MeasurePlineSeg is a special variant that measures out each segment of a pline - meaning that measurements starts over at each segment. This is only for polylines because the param-structure is different for different kind of curves (e.g. running it on a spline will almost always get you caught in an endless loop because params of a spline are calculated differently than for polylines).
(defun measureCurve (obj divDist / osm endParam dist totLen pt)
(setq osm (getvar "OSMODE")
dist 0.0
)
(setvar "OSMODE" 0)
(setq endParam (vlax-curve-getEndParam obj)
totLen (vlax-curve-getDistAtParam obj endParam)
)
(while (<= dist totLen)
(setq pt (vlax-curve-getPointAtDist obj dist)
dist (+ dist divDist)
)
(if pt (command "POINT" pt))
)
(setvar "OSMODE" osm)
)
(defun measurePlineSeg (obj divDist / osm stParam endParam nextParam segdist segdiv pt)
(setq osm (getvar "OSMODE"))
(setvar "OSMODE" 0)
(setq stParam (vlax-curve-getStartParam obj)
endParam (vlax-curve-getEndParam obj))
(while (< stParam endParam)
(setq nextParam (1+ stParam)
segdist (- (vlax-curve-getDistAtParam obj nextParam)
(vlax-curve-getDistAtParam obj stParam))
segdiv divDist)
(while (<= segdiv segdist)
(setq pt (vlax-curve-getPointAtParam obj (+ stParam (/ segdiv segdist)))
segdiv (+ segdiv divDist))
(command "POINT" pt)
)
(setq stParam (1+ stParam))
)
(setvar "OSMODE" osm)
)