Cyver
July 3, 2016, 7:24am
1
Hi all,
I’m trying to extract isocurve from surface center, like that :
Call Main()
Sub Main()
Dim strObject, arrDomainU, arrDomainV, arrParam(1), arrPoint, arrParameter, ArrDir
strObject = Rhino.GetObject("Select surface", 8, True, False)
If isnull(strobject) Then Exit Sub
ArrDir = 0
arrDomainU = Rhino.SurfaceDomain(strObject, 0)
arrDomainV = Rhino.SurfaceDomain(strObject, 1)
arrParam(0) = arrDomainU(1) / 2
arrParam(1) = arrDomainV(1) / 2
arrPoint = Rhino.EvaluateSurface(strObject, arrParam)
arrParameter = Rhino.SurfaceClosestPoint(strObject, arrPoint)
Call Rhino.ExtractIsoCurve(strObject, arrParameter, ArrDir)
End Sub
that work in most of case , but in certain case the isocurve is not extracted from center, and i need to reparametrize surface for it work.
i think the domain is not retrurned like he should be .
any idea on how to avoid this ?
Well two things possibly…
First, to find the midpoint of a domain, simply dividing the end value by two will not always work, as it assumes that the start of the domain is 0. What you need to do is average the start and end: s+e/2.
midDomainU = (DomainU(0)+DomainU(1))/ 2
Second, the midpoint of the domain may not always be the measured midpoint (lengthwise) of the surface. Curves and surfaces can have uneven parametrization, the result is mid-domain may not correspond with mid-length. To get mid length, you will need to find the actual (iso)curve length at some point, get the 3D point at mid curve length, and then find the parameter which corresponds using ClosestPoint with the curve/surface at that point.
HTH, --Mitch
Cyver
July 3, 2016, 8:46am
3
Hi Mitch,
Thanks for interesting explanations , working now !
Cyver
July 3, 2016, 6:53pm
4
Hum,
i encounter another problem if i want to divide by something else like 3 or 4 for example, or multiple in a loop
When 2 values are positive , it’s easy.
arrDomainU return value between 0 to 65.82…
arrParam(0) = ((arrDomainU(0) + arrDomainU(1)) / 3 ) = 0 + 65.82... ./ 3 = 21.94 ...
Problem come when i get negative number to positive number :
arrDomainV return -16.45… to 16.45… , in this case if i add the 2 values , i get 0 , and i can’t divide 0 by any numbers.
arrParam(1) = ((arrDomainV(0) + arrDomainV(1)) / 3 ) = -16.45 + 16.45 / 3 = 0
i don’t know how i can input negative to positive in one value , i tried many things, substract, divide etc… no luck.
Any help ?
Thx.
Willem
(Willem Derks)
July 3, 2016, 7:08pm
5
Get the length of the domain range:
delta = DomainMax-DomainMin
Divide that by the number of segments you want.
Next add that segment length to the DomainMin for each position.
Of for an arbitray single positions eg at 0.457
Parameter = DomainMin + ( delta* 0.456 )
On my phone so rather brief
-Willem
1 Like
Cyver
July 3, 2016, 9:21pm
6
Hi Willem,
i was in right direction for delta, but was missing adding the DomainMin first , it’s more clear now.
Thanks for help.
1 Like