GH inport parameter cannot be omitted

A “default” kind of problem.

I have a component which have a vector in-parameter, but I want that parameter to be optional. But if I’m not connecting a wire to the port I get a runtime error before the SolveInstance method is even entered. I tried setting an empty vector as default (well, zero length vector instance) but that didn’t help.

protected m_dirToDelete = new Vector3d(0,0,0);
IP_BackFaceDir = pManager.AddVectorParameter("Back Face Direction", "BFC", "...", GH_ParamAccess.item, m_dirToDelete);

I also test-read the input parameter like so, but the component still reports “Input parameter ‘so and so’ failed to collect data”:

if (!DA.GetData(IN_BackFaceDir, ref m_dirToDelete))
	m_dirToDelete.X = 0;
	m_dirToDelete.Y = 0;
	m_dirToDelete.Z = 0;

So how can I configure a component to accept an empty in-port?

// Rolf

Inside the RegisterInputParams method, after adding the vector parameter, call pManager[i].IsOptional = true;

1 Like