to creat a true lenear dimension we need something like this:
Plane currentDocPlane1 = RhinoDoc.ActiveDoc.Views.ActiveView.ActiveViewport.ConstructionPlane();
Plane currentDocPlane2 = RhinoDoc.ActiveDoc.Views.ActiveView.ActiveViewport.ConstructionPlane();
Transform rotation = Transform.Rotation(Math.PI / 2, Point3d.Origin);
Plane currentDocPlane =currentDocPlane1 ;
if(....) currentDocPlane = currentDocPlane2;
currentDocPlane2.Transform(rotation);
and some boolean checking based on the current coordinates of the 3rd point.
for default the
Assistant
To create a true linear dimension in Rhino using C#, you need to consider transforming the construction planes and using conditions to determine which plane to use based on the orientation of your geometry. Here's a more structured approach to adjust your planes and set up your dimension correctly:
Define the Planes:
You initialize two planes, which likely represent two orientations you want to check against. One plane stays in its initial state, while the other is rotated by 90 degrees (π/2 radians).
Transform the Plane:
You apply a rotation transformation to the second plane about the origin or another suitable point. Make sure the rotation is around the correct axis, usually the Z-axis if you're working in the XY plane.
Conditionally Choose the Plane:
Based on some criteria—potentially involving checking the coordinates of a third reference point—you decide which plane to use for the dimension.
Here is an approach to integrate these steps in your script:
csharp
// Assuming you're working within a method that has access to the Rhino environment
// Step 1: Define and initialize planes
Plane currentDocPlane1 = RhinoDoc.ActiveDoc.Views.ActiveView.ActiveViewport.ConstructionPlane();
Plane currentDocPlane2 = currentDocPlane1; // Create a copy to apply a separate transformation
// Step 2: Apply a rotation to the second plane
Transform rotation = Transform.Rotation(Math.PI / 2, currentDocPlane2.ZAxis, currentDocPlane2.Origin);
currentDocPlane2.Transform(rotation);
// Step 3: Determine which plane to use
// For example, you could check the orientation of an object against these planes
// Here we'll use some pseudo-code to represent this decision-making process
bool useSecondPlane = false; // Placeholder for your actual condition
if (/* some boolean condition checking the 3rd point or another criteria */)
{
useSecondPlane = true;
}
Plane currentDocPlane = useSecondPlane ? currentDocPlane2 : currentDocPlane1;
// Now you can use `currentDocPlane` to create your linear dimension or for further operations
// Example of working with points and dimensions
Point3d point1 = new Point3d(0, 0, 0); // Example points, replace with actual points
Point3d point2 = new Point3d(10, 0, 0);
LinearDimension linearDimension = new LinearDimension(currentDocPlane, point1, point2, point2);
RhinoDoc.ActiveDoc.Objects.AddLinearDimension(linearDimension);
Key Considerations:
Coordinate Checks: The conditions to select between currentDocPlane1 and currentDocPlane2 should be based on your specific need, which might involve coordinate comparisons, angle checks, or object alignments.
Orientation: Ensure that your rotations occur around the desired axis and origin. Depending on your usage and geometry, you might need to adjust these parameters.
Rhino Environment: This script assumes running within Rhino's .NET SDK environment, so ensure your project is set up correctly with necessary references to RhinoCommon.
This script provides a template and a conceptual framework; you must refine the conditions and coordinate logic to fit your specific use case and geometry requirements in Rhino.