How to find the corresponding rhino command in API in Rhinocommon?

(Andrealu2012) #1

For example,in Rhino there is “SrfSeam” command to change the seam of surface,but when I want to write c# component,I cannot find which API is corresponding to “SrfSeam”…who can help me?thank you!

How to invoke "SrfSeam" command in c#?
(Michael Pryor) #2

Surface seam is not in Rhinocommon yet.

(Andrealu2012) #3

thankyou Pryor.
then…how to invoke a rhino command in c#,such as “srfseam”?

(qythium) #4

You could use RhinoApp.RunScript which allows you to run any Rhino command or macro from C#.

PS. no need to start a new topic for the same question, you can edit the original topic title instead.

(Andrealu2012) #5

thank you,i qythium,i understand

(David Rutten) #6

It is messy and complicated from within Grasshopper. You must:

  1. Insert the surface into the Rhino document.
  2. Make sure it (and nothing else) is selected.
  3. Compose a command macro to run. It’ll look something like "-_SrfSeam w12.5,3.8,0"
  4. Invoke RhinoApp.RunScript() with your macro.
  5. Find your modified surface object (it should still be the only one selected).
  6. Read in the new surface geometry.
  7. Delete the object.
  8. Possibly restore the selected state from before point [1].

(David Rutten) #7

srfseam (75.3 KB)

(Andrealu2012) #8

Thank you very much David,i have read your code,it is what i want!,but i also want to make the code understand,because i need to code a lot later…the code below:

string macro = string.Format("-_SrfSeam w{0},{1},{2}", P.X, P.Y, P.Z);
I suppose this sentence is for composing the marco,…and what is Format method means?thank you

(qythium) #9

The curly brackets refer to positional arguments, and get replaced with the string representation of P.X, P.Y and P.Z.

Here’s a graphic showing how it works in Python

(syntax is similar, couldn’t find one for C#)

(David Rutten) #10

string.Format() allows you to compose strings in a reasonably readable fashion. Instead of typing:

string macro = "-_SrfSeam w" + P.X.ToString() + "," + P.Y.ToString() + "," + P.Z.ToString()

You can use the {0} as placeholders. Search for the string.Format method on msdn and you’ll get a lot of information about patterns and stuff.

(Andrealu2012) #11

thank you!

(Andrealu2012) #12

thank you!!