NO&BR_infect path from path _ max dist

Option Explicit
‘Script written by <naomi ocko and ben riley>
‘Script copyrighted by <insert company name>
‘Script version Monday, 09 November 2009 18:58:49

Call Main()
Sub Main()

 Dim i,j,k
 Dim acs, apts
 Dim aPlan, dRad, dRadMax, dRadDefault
 Dim sCrv, aparam
 Dim aPt, aPtOnCrv
 Dim dTreshold, dD
 ‘Dim RedIDs
 Dim Allpts
 Dim dThresh
 ‘Dim iterations
 Dim sp, sC
 Dim nFibers ‘aptsCircle
 Dim vect,mid
 ‘Allpts = rhino.GetObjects (“sel pts”,1)
 acs = rhino.GetObjects(“pick crvs”, 4)
 If isnull(acs) Then Exit Sub
 
 sCrv = rhino.GetObject(“pick path”, 4)
 If isnull(sCrv) Then Exit Sub
 
 ‘dTreshold value was 3
 dTreshold = 7
 dRadMax = .1
 dRadDefault = 0.001
 
 Call Rhino.EnableRedraw(False)
 ” ———————————————————–
 ” divide crvs
 For i=0 To ubound (aCs)
  mid = rhino.CurveMidPoint (aCs(i))
  aParam = rhino.CurveClosestPoint(sCrv, mid)
  aPtOnCrv = rhino.EvaluateCurve(sCrv,aParam)
  
  dD = xyDist (mid,aPtOnCrv)
  
  
 
  apts = rhino.DivideCurveLength(aCs(i), 0.1)
  
  
  ReDim aptsCircle(UBound(apts))
  For j = 0 To UBound(apts)
   
   ” PT
   ‘sp = rhino.addPoint(apts(j))
   
   ”PATH
   aParam = rhino.CurveClosestPoint(sCrv, aPts(j))
   aPtOnCrv = rhino.EvaluateCurve(sCrv,aParam)
   dD = xyDist (aPtOnCrv,aPts(j))
   
   ” RAD
  
   
   ‘If dD < dTreshold Then
   If dD < random(.0001, 1)* dTreshold Then
   ‘If dD < random(.1,.7)* dTreshold Then    ‘dRad = dRadmax – (dRadMax * dD/dTreshold)
    ‘zdist = abs (aPts(j)(2),aPtOnCrv(2))
    ‘dRad = (dRadMax*(dD^2/dTreshold)) + dD/30
    ‘If dD < 1.5 then
     dRad = (dRadMax*(dD^2/dTreshold)) + dRadDefault
    ‘Else dRad = dRadMax
     
    ‘End If
     
     
    ‘vect = rhino.vectorcreate (aPts(j),aPtOnCrv)
    ‘vect = rhino.vectorscale (vect, 0.66)
    ‘aPts(j) = rhino.PointAdd (aPts(j),vect)

   
    aPlan = Rhino.MovePlane(Rhino.WorldXYPlane(),aPts(j))
    sC = Rhino.AddCircle (aPlan,dRad)
    
    ‘dRad = dRadMax
   End If
   
   
   
   
  Next
  
 Next
 
  

 Call Rhino.EnableRedraw(True)
 
End Sub
Function xyDist (pt1,pt2)
 Dim d,pt1f,pt2f
 
 pt1f = rhino.PointAdd (pt1,array(0,0,-pt1(2)))
 pt2f = rhino.PointAdd (pt2,array(0,0,-pt2(2)))
 
 d = rhino.Distance (pt1f,pt2f)
 xyDist = d
 
 
 
End Function
Function Random (min, max)

 Random = Rnd*(max-min) + min

End Function

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s