22 February 2010

RH convert annotation dots to points

In these days at ZHA office we needed a quick and fast task to rename and manage annotation dots created previously. I wrote and custom for our purpose a series of RhinoScript from one of the codes archived on McNeel website .

1.RH convert_annotation_dot_to_points

Option Explicit
'Script written by Davide del Giudice
'Script copyrighted by Co-de-iT www.co-de-it.com
'Script version Sunday, 21 February 2010 20:40:21

Call convert_annotation_dot_to_points()

Sub convert_annotation_dot_to_points()

Dim arrDots, strDot
arrDots = Rhino.GetObjects("Select dots", 0, True, True )

If Not IsArray(arrDots) Then Exit Sub

Dim arrPt, strText

For Each strDot In arrDots
If Rhino.IsTextDot(strDot) Then
strText = Rhino.TextDotText(strDot)
arrPt = Rhino.TextDotPoint(strDot)
Rhino.AddPoints array(arrPt)

'Rhino.AddText strText, arrPt
Rhino.DeleteObject strDot

End If
Next
End Sub






2.
RH convert_annotation_dot_to_points_coordinates

Option Explicit
'Script written by Davide del Giudice
'Script copyrighted by Co-de-iT www.co-de-it.com
'Script version Sunday, 21 February 2010 20:40:21

Call convert_annotation_dot_to_points_coordinates2()
Sub
convert_annotation_dot_to_points_coordinates2()

Dim arrDots, strDot
arrDots = Rhino.GetObjects("Select dots", 0, True, True )
If Not IsArray(arrDots) Then Exit Sub

Dim arrPt, strText
For Each strDot In arrDots
If Rhino.IsTextDot(strDot) Then
strText = Rhino.TextDotText(strDot)
arrPt = Rhino.TextDotPoint(strDot)
Rhino.AddPoints array(arrPt)

Rhino.DeleteObject strDot


Rhino.AddTextDot "pt"& "_"& strText& "_"& Rhino.Pt2Str(arrPt, 3) , arrPt
'Rhino.AddText "pt"& "_"& strText& "_"& Rhino.Pt2Str(arrPt, 3) , arrPt
End If
Next
End Sub

2a.RH points_coordinate_ from_points


Option explicit
Call points_coordinate_from_points()
Sub
points_coordinate_from_points()

Dim arrObjects, strObject
arrObjects = Rhino.GetObjects("Select points", 1, True, True )
If Not IsArray(arrObjects) Then Exit Sub

Dim arrPoint, strText
For Each strObject In arrObjects

arrPoint = Rhino.PointCoordinates(strObject)

'Rhino.DeleteObject strObject
'change number after arrPoint to change rounding approximation
Rhino.AddTextDot "pt"& "_"& Rhino.Pt2Str(arrPoint, 0), arrpoint
'Rhino.AddText "pt"& "_"& "5"& Rhino.Pt2Str(arrPoint, 3) , arrpoint

Next
End Sub


3.RH convert_annotation_dot_to_points_copy_label_to_points

Option Explicit
'Script written by Davide del Giudice
'Script copyrighted by Co-de-iT www.co-de-it.com
'Script version Sunday, 21 February 2010 20:40:21
'Script adaptation from www.kokkugia.com

Call convert_annotation_dot_to_points_copy_label_to_points()
Sub
convert_annotation_dot_to_points_copy_label_to_points()

Dim arrDots, strDot
arrDots = Rhino.GetObjects("Select annotation dots", 0, True, True )


If Not IsArray(arrDots) Then Exit Sub

Dim arrPt, strText
For Each strDot In arrDots
If Rhino.IsTextDot(strDot) Then
strText = Rhino.TextDotText(strDot)
arrPt = Rhino.TextDotPoint(strDot)
Rhino.AddPoints array(arrPt)
'Rhino.AddText strText, arrPt
Rhino.DeleteObject strDot
End If
Next

MsgBox "First of all, remember to place your copy object at X,Y,Z Origin"

Dim obj,pts,i,pointCoord


'input -points+objec
obj=Rhino.GetObject("select object to copy")
pts=Rhino.GetObjects("select points to copy to")
'loop through all the points
For i=0 To Ubound(pts)
'get the position of the point
pointcoord=rhino.PointCoordinates(pts(i))
'copy object to tha position
Rhino.CopyObject obj,array(0,0,0),pointcoord
Next
Msgbox "visit http://www.co-de-it.com for more stuff"

End Sub

0 commenti: