algorithmic modeling for Rhino
Tags:
pManager.Register_StringParam("Variant Name", "Variant", "Variant name, "test", GH_ParamAccess.item)
pManager.Register_BRepParam("Geometry 2", "Geo2", "List of Breps", GH_ParamAccess.list)
'the Brep param is index 1
pManager(1).Optional = True
Register_XXXXParam methods have been replaced by AddXXXXParameter in some recent version.
Making parameters optional is done with:
pManager(2).Optional = True
in case the third input has to be optional.
--
David Rutten
david@mcneel.com
Poprad, Slovakia
You do this in RegisterInputParams() right?
--
David Rutten
david@mcneel.com
Poprad, Slovakia
That is very strange. Which exact error do you get:
Can you post a screenshot of the component with the error and your RegisterInputParams code?
--
David Rutten
david@mcneel.com
Poprad, Slovakia
Sorry Hans but I simply cannot repeat that.
I pasted your code into a blank component and it works as expected:
Public Class testcomponent
Inherits GH_Component
Public Sub New()
MyBase.New("Bla", "Blah", "yada yada", "cat", "sub")
End Sub
Public Overrides ReadOnly Property ComponentGuid As System.Guid
Get
Return Guid.NewGuid
End Get
End Property
Protected Overrides Sub RegisterInputParams(pManager As Kernel.GH_Component.GH_InputParamManager)
pManager.AddBooleanParameter("Boolean", "B", "Turn the component on or off", GH_ParamAccess.item)
pManager.AddTextParameter("String", "N", "New Parameters", GH_ParamAccess.item)
pManager.AddTextParameter("String", "I", "Input file path", GH_ParamAccess.item)
pManager.AddTextParameter("String", "L", "Local copy path", GH_ParamAccess.item)
pManager.AddTextParameter("String", "U", "User Name", GH_ParamAccess.item)
pManager(2).Optional = True 'this doesn't work
pManager(3).Optional = True
End Sub
Protected Overrides Sub RegisterOutputParams(pManager As Kernel.GH_Component.GH_OutputParamManager)End Sub
Protected Overrides Sub SolveInstance(DA As Kernel.IGH_DataAccess)End Sub
End Class
Could it perhaps be that the component you're writing is not the same one that GH is loading? It's the only idea I have left at this point.
--
David Rutten
david@mcneel.com
Poprad, Slovakia
Just in case. For C# this is
pManager[2].Optional = true;
Posted in 2020
Very late, but maybe it helps somebody;
To make it work in C# you need to write
pManager[1].Optional = true;
Important is to use square brackets instead of parenthesis around the number!
Good luck!
Roman
Thanks Roman,
Better late than never ;)
Thanks!
This saved my life... Two fixed from the above posted fix.
-Use square brackets in C#
-And use lowercase in true
Welcome to
Grasshopper
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
© 2024 Created by Scott Davidson. Powered by