rvb Autodimension

add surface tabs

Autodimension tool. It works properly for polylines, not so much for closed lines or curves. Additionaly, it creates a new layer where it creates the actual dimensions, so you do not need to worry about messing with your layer structure.

Option explicit

' Script written by Jan Hempel

' Modified by Adolfo Nadal

'Script by archiologics · www.archiologics.com

Call autodimension()

Sub autodimension()

Dim arrPolycrv: arrPolycrv = Rhino.GetObjects("select lines",4)

Dim dblOffset : dblOffset = rhino.GetReal ("dimension Distance (out = pos., in = neg.) :",5)

Dim Line, arrLine, i, strSrf

If isNull (arrLine) Then Exit Sub

Call Rhino.EnableRedraw (False)

Call Rhino.AddLayer ("DIMENSIONS",RGB(255,0,0))

Call Rhino.CurrentLayer ("DIMENSIONS")


For i = 0 To Ubound(arrPolycrv)

If Rhino.IsCurve(arrPolycrv(i)) And Rhino.IsCurveClosed(arrPolycrv(i)) Then

arrLine = rhino.ExplodeCurves (arrPolycrv(i))

If Not isnull(arrLine) Then

If IsArray(arrLine) And Ubound(arrLine) > 0 Then

strSrf = Rhino.AddPlanarSrf(arrLine)(0)

For Each Line In arrLine

Call dimension(Line, strSrf, dblOffset)


Call rhino.deleteObjects (arrLine)

Call rhino.deleteObject (strSrf)

End If

End If

End If


'Rhino.MessageBeep 1

Call Rhino.EnableRedraw (True)

End Sub


Sub dimension(line, strSrf, dblOffset)

Dim a,b,c,point,point2,strp,strq,arrStartPt, arrEndPt,arrMP

Dim midPt, V1, V2, V3, V4, Pt01, Pt02, arrDstPt


arrStartPt = Rhino.CurveStartPoint( line)

arrEndPt = Rhino.CurveEndPoint( line)


midPt = Rhino.CurveMidPoint(line)

V1 = Rhino.VectorCreate(midPt, arrStartPt)

V1 = Rhino.VectorUnitize(V1)

V1 = Rhino.VectorScale(V1, 0.5)

V3 = Rhino.VectorScale(V1, 2*dblOffset)

V3 = Rhino.VectorRotate(V3, 90, array(0,0,1))

V4 = Rhino.VectorRotate(V3, 180, array(0,0,1))

V1 = Rhino.VectorRotate(V1, 90, array(0,0,1))

V2 = Rhino.VectorRotate(V1, 180, array(0,0,1))

Pt01 = Rhino.VectorAdd(midPt, V1)

Pt02 = Rhino.VectorAdd(midPt, V2)


If Not Rhino.IsPointOnSurface(strSrf, Pt01) Then

arrDstPt = Rhino.VectorAdd(midPt, V3)


arrDstPt = Rhino.VectorAdd(midPt, V4)

End If


a = Rhino.Pt2Str(arrStartPt)

b = Rhino.Pt2Str(arrEndPt)

c = Rhino.Pt2Str(arrDstPt)


rhino.Command "_DimAligned " & a &" "& b &" "& c

rhino.deleteObject line

End Sub

Search Site

archi·o·logics survey

I am interested in: