Use of Rhinoscript within Excel VBA

Hello All,
I am interested in automating some of the drawings that i need to use in my other work related software.
That s why i would like to get a hold of the syntax of some operations that i can use in excel VBA.
The simplest type of a drawing that i can do in Rhino is by simply connecting the dots and create lines.

The Code Below is using the Line Command to draw simple lines to create a prismatic element. If you put this in excel vba macro and run it then you will get a prismatic element in Rhino.

Rather than using Lines , i would like to know the Syntax of Command to create a surface created by 4 dots. By creating 6 surface i can still make up a prismatic member.

If there is anyone out there who can help me on this , I would appreciate it.
All i want to know is the Syntax of Command that creates a surface in Rhinoscript that i can insert like seen in the example below within Excel VBA.

I also include another code that I figured out in Python that can create surface but that syntax will not work for VBA.

Thanks

Celal Kirandag

==> Excel VBA Code to Draw a prismatic element in Rhino

Dim Rhino As Object
Dim objRhinoScript

On Error Resume Next

’ Set Rhino to Running Rhino
'****************************
Set Rhino = CreateObject(“Rhino.Interface.7”) ’ Set Rhino = CreateObject(“Rhino.Application”)
If VBA.IsNull(“False”) Then Exit Sub


Rhino.Visible = True


’ Try getting RhinoScript object
'*********************************
Set objRhinoScript = Rhino.GetScriptObject

Dim pt0

objRhinoScript.Command “_Line w10.0,-10.0,0.0 w10.0,10.0,0.0”
objRhinoScript.Command “_Line w10.0,10.0,0.0 w-10.0,10.0,0.0”
objRhinoScript.Command “_Line w-10.0,10.0,0.0 w-10.0,-10.0,0.0”
objRhinoScript.Command “_Line w-10.0,-10.0,0.0 w10.0,-10.0,0.0”

objRhinoScript.Command “_Line w10.0,-10.0,10.0 w10.0,10.0,10.0”
objRhinoScript.Command “_Line w10.0,10.0,10.0 w-10.0,10.0,10.0”
objRhinoScript.Command “_Line w-10.0,10.0,10.0 w-10.0,-10.0,10.0”
objRhinoScript.Command “_Line w-10.0,-10.0,10.0 w10.0,-10.0,10.0”


objRhinoScript.Command “_Line w10.0,-10.0,0.0 w10.0,-10.0,10.0”
objRhinoScript.Command “_Line w10.0,10.0,0.0 w10.0,10.0,10.0”
objRhinoScript.Command “_Line w-10.0,10.0,0.0 w-10.0,10.0,10.0”
objRhinoScript.Command “_Line w-10.0,-10.0,0.0 w-10.0,-10.0,10.0”

If Err.Number <> 0 Then

VBA.MsgBox “Failed to create Rhino object.”
Exit Sub

End If

VBA.MsgBox “Rhino object created.”

End Sub

==>Python Code to Draw a prismatic element in Rhino

from Rhino.Geometry import NurbsSurface, Point3d
from scriptcontext import doc

surface1 = NurbsSurface.CreateFromCorners(
Point3d(100, -100, 0),
Point3d(100, 100, 0),
Point3d(-100, 100, 0),
Point3d(-100, -100, 0));
doc.Objects.AddSurface(surface1);

surface2 = NurbsSurface.CreateFromCorners(
Point3d(100, -100, 100),
Point3d(100, 100, 100),
Point3d(-100, 100, 100),
Point3d(-100, -100, 100));

doc.Objects.AddSurface(surface2);

surface3 = NurbsSurface.CreateFromCorners(
Point3d(100, -100, 0),
Point3d(100, 100, 0),
Point3d(100, 100, 100),
Point3d(100, -100, 100));

doc.Objects.AddSurface(surface3);

surface4 = NurbsSurface.CreateFromCorners(
Point3d(-100, -100, 0),
Point3d(-100, 100, 0),
Point3d(-100, 100, 100),
Point3d(-100, -100, 100));

doc.Objects.AddSurface(surface4);

surface5 = NurbsSurface.CreateFromCorners(
Point3d(-100, -100, 0),
Point3d( 100, -100, 0),
Point3d( 100, -100, 100),
Point3d(-100, -100, 100));

doc.Objects.AddSurface(surface5);

surface6 = NurbsSurface.CreateFromCorners(
Point3d(-100, 100, 0),
Point3d( 100, 100, 0),
Point3d( 100, 100, 100),
Point3d(-100, 100, 100));

doc.Objects.AddSurface(surface6);

doc.Views.Redraw();

Hi @Celal_KIRANDAG,

The RhinoScript equivalent to NurbsSurface.CreateFromCorners is AddSrfPt.

You can use Rhino.Python in VBA. For example, instead of doing this:

objRhinoScript.Command "_Line w-10.0,-10.0,0.0 w-10.0,-10.0,10.0"

Do something like this:

objRhinoScript.Command "_-RunPythonScript <path_to_script_file>"

– Dale

Thanks Dale.
I will try and let you know.

Does it also mean to say that every Python Syntax would work under Rhinoscript if I write in this manner in the VBA Code?

Let me know

Celal

Sorry, I’m not sure what this means.

All I was suggesting was to have Rhino run your saved Python scripts.

https://docs.mcneel.com/rhino/7/help/en-us/index.htm#commands/runpythonscript.htm

– Dale

Sorry for confusion.
What i was asking that in that syntax you wrote "objRhinoScript.Command “_-RunPythonScript <path_to_script_file” , Can this be run like that within Excel VBA file?
Thanks

Celal