Hi,
When I Construct two cylinders in two different ways (with curve/GH, and direct draw in Rhino) and then Deconstruct them and Construct them again, the resulting cylinders are different . The Brep version gets the radius wrong, and resizes when rotated, and the axis direction is from top --> down, while the curve based cylinder constructed in GH behaves as expected (doesn’t resize during rotation, axis direction ccording to the direction if the inital line, etc). Identical
The Brep (the lower cylinder) seems to have a problem stemming from Brep.GetBoundingBox() while the same code (Brep.GetBoundingBox()) works fine on the first cylinder which were created from a curve/line (upper definition).
Why is this? And how do I properly deconstruct a cylinder so that it doesn’t matter how it was originally created?
Fig. 1. Two Cylinders created in two different ways - one from a curve, and the other one by direct draw in Rhino (passed on into GH via Brep):
Different types of geometry can all look like cylinders. In order to deconstruct them you’ll have to write special code for each type. Rhino.Geometry.Brep, Rhino.Geometry.NurbsSurface, Rhino.Geometry.RevSurface, Rhino.Geometry.SumSurface, Rhino.Geometry.Cylinder, Rhino.Geometry.Extrusion.
Although there is the TryGetCylinder method, so maybe that will work on all surface types.
but then I only discovered a third case: when feeding the Cyl-component directly with a vector instead of the PlaneNormal component, see red-marked case .
I noticed that both the directions and the axis end pojnts can be switched, so “extending” the cylinder may gop in the wrong direction, and the Plane located in the wronf end, and… (ok, plane-version fixed but).
Q: So, how can I determine the different cases? (Like in this case when the Cylinder was created with the Vector instead of the PlaneNormal component?)
There were no script components. That file only had the components already shown in your screencap. The 02 file uploaded later does have it, so now I can have a look at the code.
You can’t. The BRL Cylinder component takes a Plane, a Radius and a Height. If you decide to feed a vector into the plane input, then it will be converted into a plane before the component itself gets to have a look. The automatic conversion from vector → plane is not particularly sensible because it strings together two other automatic conversions.
First the vector becomes a point through simple coordinate copying (i.e. the vector (6,8,-2) becomes the point (6,8,-2)), then the point becomes a plane which is parallel to WorldXY but centred at (6,8,-2). So basically the plane used in the red-marked case is just a horizontal plane at the tip of the vector.
Automatic type conversions that happen inside the input parameters are not detectable later on. The output is just a cylinder, always of the same data type.
Anyway, thanks for the information. I know that it’s abuse to use vectors, but every now and then there will be a shortcut due to convenience… gotta watch out for that.