f.kato
(F Kato)
1
Hi,
This is my first post, and very basic question in rhinocommon.
I am trying to my personal command which is to pick a cylinder and change its diameter.
On RhinoCommonGuides page there example like this;
const ObjectType geometryFilter = ObjectType.Surface | ObjectType.PolysrfFilter | ObjectType.Mesh;
Then, I went to ObjectType page in RhinoCommon API, but Cylinder is not on there.
I also found GetCylinder class, but I cannot use the class like GetObject class.
I would like to make script just like this,
const ObjectType geometryFilter = ObjectType.Cylinder;
GetObject go = new GetObject();
go.SetCommandPrompt(“Select a Cylinder”);
go.GeometryFilter = geometryFilter;
GetResult res = go.GetMultiple(1, 1);
If someone give me an advise for that, I would appreciate.
Willem
(Willem Derks)
2
Hi.
If I’m not mistaken:
Once a Cylinder is added to the document, it becomes a cylindical shaped brep. There is longer a link to the parametrics of the cylinder.
What you could do however is get the underlying surface of the cylinder shaped brep and test for it to be a cylinder with:
https://developer.rhino3d.com/api/RhinoCommon/html/M_Rhino_Geometry_Surface_TryGetCylinder.htm
From there you can create a new cylinder.
Does that make sense
-Willem
Hi @f.kato,
You can create your own custom filter by setting filter callback function using GetObject.SetCustomGeometryFilter() method as follows:
public bool MyCylinderFilter(RhinoObject rhObject, GeometryBase geometry, ComponentIndex componentIndex)
{
if (geometry is Surface srf)
{
Cylinder cyl;
bool isCylinder = srf.TryGetCylinder(out cyl);
return isCylinder;
}
return false;
}
Then set it to your GetObject instance.
GetObject gO = new GetObject();
gO.SetCustomGeometryFilter(MyCylinderFilter);
f.kato
(F Kato)
4
Thank you guys!
Now you lift up my motivation for studying rhinocommon.
Hope I will be the guy like you who helps people on this forum.
Have a great day!!!