![]() |
=======================START of SCRIPT (name it something.rvb)
'Using the class MyClassA
Sub ClassTest()
Set obj = New MyClassA
ClassAssigned
If mycheck
= true then
obj.ClassMsg "OoO
I am in here!"
'done with obj empty/release it
Set obj = Nothing
else
msgbox "EMPTY/NON EXISTING OBJECT"
End If
End Sub
' assign class only once
Sub ClassAssigned
'check for existence of the object
MyCheck = IsObject(obj)
'let see do we already have an object or obj
is empty
If
MyCheck = False or IsEmpty(obj) then
msgbox "Obj hasn't been defined"
else
msgbox "Obj HAS been defined"
End If
End Sub
'global declaration of the variables
Dim obj, MyCheck
'******separate this if we want to run it more
than once (see below) but
'for testing purpose to see how class has
been implemented this is fine
Class MyClassA
Sub ClassMsg(msg)'Method
classmsg
MsgBox msg
End Sub
End Class
'*****end separate
'rhinoscript
ClassTest
=====================END of SCRIPT|
Note the above script will run only once so we have
to do the following to run this multiple times:
cut:
'******separate this
Class MyClassA
'Method classmsg
Sub ClassMsg(msg)
MsgBox msg
End Sub
End Class
'*****end separate
from the list above and save it as a separate script file let say initclass.rvb
Start Rhino->Tools->Options->RhinoScript->StartUp
File Settings->StartUpFile
c:\rhino20\scripts\initclass.rvb
|============| this
portion may be different on your computer
This will load class MyClassA (only once) at Rhino's startup so we can use and reuse them later
LoadScript and select something.rvb
Voila