ScriptSpot

Forum topic · Scripts Wanted

Average vertices in z axis

By aftersukho · 2015-03-14

Description
Attachments
Comments (3)

aftersukho · 2015-03-21

thank for comment

i want to do facade/skin design,It can be Measure

and i must to do drawing (autocad)

i just want to average vertices in my curve
1.set height of top vertex
2.set height of base vertex
3.average vertices between base-top

i don't know how to do , method to do
i can do one by one, first i must be divide height and set height all vertices by my hand

It's my thesis, Faculty of architecture

Sorry, I'm not fluent in Enlish,but I will try my best explaining to you.

thank for help

`

pixamoon · 2015-03-23

Oki,

I think this should work:


(
	local len = 0,
		startPos = (getKnotPoint $ 1 1),
		endPos = (getKnotPoint $ 1 (numKnots $ 1)),
		zDiff = endPos.z - startPos.z,
		distFromStart = 0
		
	---- get lenght of Z flatten spline 
	for k = 2 to numKnots $ 1 do 
	(
		knt0 = (getKnotPoint $ 1 (k-1))
		knt1 = getKnotPoint $ 1 k
		len += (distance [knt0.x, knt0.y, 0] [knt1.x, knt1.y, 0])
	)		
			
	-- calculate and set avarage vert z axis pos
	for k = 2 to (numKnots $ 1) - 1 do 
	(
		knt0 = (getKnotPoint $ 1 (k-1))
		knt1 = getKnotPoint $ 1 k
		
		distFromStart += distance [knt0.x, knt0.y, 0] [knt1.x, knt1.y, 0]
			
		newPos = [knt1.x, knt1.y, (startPos.z + (distFromStart/len * zDiff))]
		
		setKnotPoint $ 1 k newPos
	)
	updateshape $
)

It works only if you select single spline and run script.
Cheers,
Pixamoon

Attachments

re: heights

pixamoon · 2015-03-18

hi,

I'm not sure how you want to specify heights

Just with CurveControl or read values from txt/csv file ?