| |
|
Clean Code
Here comes a better version of the ScaleFactor script slighty changed
to make it more userfriendly, and with some error checking.
You might find a online help for VBscript on the Microsoft site. Further
there is a RhinoScript help file in the plugins folder, that you can open
by the Rhino Menue: Help > PlugIns > RhinoScript. It contains sample code
for each RhinoScript method (thanks Dale Fugier!)
|
|
| |
Sub ScaleFactor()
'/////////////////////////////////////////////////////////////////
'// VBscript to calculate a Scaling Factor (Rhino V3 SR3)
'// 02.10.2003 © Jess Märtterer - www.rhino3.de
'/////////////////////////////////////////////////////////////////
' Initialize Variables
Dim arrPoints, dblDistance
Dim currLocale, dblNewDistance, dblScale
' Input of two points
arrPoints = Rhino.GetPoints (true, false, "First Point", "Second Point", 2)
' if picking points was success
If IsArray(arrPoints) Then
' Calculate the distance between the points
dblDistance = Rhino.Distance(arrPoints(0), arrPoints(1))
' Go on if distance is not Null
If Not IsNull(dblDistance) Then
' Enter new desired Distance
dblNewDistance = Rhino.GetReal("Enter New Distance", dblDistance)
' Weiter wenn Soll-Wert ein gültiger Wert ist UND ungleich IST-Wert
If Not IsNull(dblNewDistance) And dblNewDistance <> dblDistance Then
' Get the regional setting and store it in currLocale
' set the regional setting to EN-US
currLocale = SetLocale ("en-us")
' calculate the scale factor
dblScale = dblNewDistance / dblDistance
' evoke the native Rhino command with the calculated scale value
Rhino.Command "_Scale2D _Pause _Copy=No _Pause " & CStr(dblScale)
' Set back the regional settings
SetLocale currLocale
End If
End If
End If
End Sub
ScaleFactor
|