Grasshopper

algorithmic modeling for Rhino

Can someone point out whether there is any problem with the script below.

No error messages are generated but the step file does not get imported.

Many thanks

Private Sub RunScript(ByVal ManualTrigger As Object, ByVal Rootfile As Object, ByRef A As Object)
    Dim Path2 As String
    Path2 = Left(RootFile, len(RootFile) - 4) + "-SelectedPoints.stp"
    print(Path2)
    rhino.rhinoapp.runscript("-_import " + "" + Path2 + "" + "_ENTER", False)

  End Sub

Views: 1040

Replies to This Discussion

This is VBScript code trying to run in a VB.NET environment. It's not necessarily going to fail, but it definitely relies on a lot of legacy methods to be in place.

VB string concatenation happens with the '&' operator, not the '+' operator.

First of all I'd recommend setting the input type hints on your component parameters. Object is not that helpful. Either set them to String, or Boolean, or whatever the data is supposed to be.

I've rewritten the function using a VB.NET approach.

Private Sub RunScript(ByVal ManualTrigger As Boolean, ByVal Rootfile As String, ByRef A As Object)

    If (Not ManualTrigger) Then Return

    Rootfile = Rootfile.SubString(0, Rootfile.Length - 4)

    Dim path As String = Rootfile & "-SelectedPoints.stp"

    Rhino.RhinoApp.WriteLine("path: " & path)

    Dim command As String = String.Format("-_Import ""{0}"" _Enter", path)

    Rhino.RhinoApp.WriteLine("command: " & command )

    Rhino.RhinoApp.RunScript(command, False)

End Sub

Thank you David for your help!!

RSS

About

Translate

Search

Photos

  • Add Photos
  • View All

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service