### Author Topic: Division of objects  (Read 5215 times)

0 Members and 1 Guest are viewing this topic.

#### rugaroo

• Bull Frog
• Posts: 378
##### Division of objects
« 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
LDD06-09 | C3D 04-19 | Infraworks 360 | VS2012-VS2017

• Guest
##### Division of objects
« Reply #1 on: October 09, 2003, 07:21:14 AM »
Specified increments? Yes, MEASURE

DIVIDE does not specify increments but number of parts.

• Guest
##### Division of objects
« Reply #2 on: October 09, 2003, 07:52:31 AM »
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).

Code: [Select]
(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)
)