Creating Section of Solid in Drawing
I could not get section of Truss (solid) by using following code.
private void Truss2DDrawingKalip_Shown(object sender, EventArgs e)
{
var sheet = new devDept.Eyeshot.Sheet(devDept.Geometry.linearUnitsType.Centimeters, 42, 29.7, "Truss Elevation", 0);
kalipDrawing.Sheets.Clear(); // Remove old sheets (optional but safe)
kalipDrawing.Sheets.Add(sheet); // Add your new sheet
kalipDrawing.ActiveSheet = sheet; // Make it visible
kalipDrawing.Invalidate(); // Force redraw to update UI
var fullDesign = designKalipDoc; // your original full model
fullDesign.Entities.Regen();
// Compute the bounding box of the model
var bboxMax = designKalipDoc.Entities.BoxMax;
var bboxMin = designKalipDoc.Entities.BoxMin;
double centerX = sheet.Width / 2;
double centerY = sheet.Height / 2;
// Get corners properly
Point3D minPt = new Point3D(bboxMin.X, 0, bboxMin.Z);
Point3D maxPt = new Point3D(bboxMax.X, 0, bboxMax.Z);
// Compute width and height
double modelWidth = maxPt.X - minPt.X;
double modelHeight = maxPt.Z - minPt.Z;
double scaleX = sheet.Width / modelWidth * 0.8; // 80% of sheet
double scaleY = sheet.Height / modelHeight * 0.8; // 80% of sheet
double scale = Math.Min(scaleX, scaleY);
// Create a centered VectorView
var frontView = new VectorView(centerX, centerY, devDept.Eyeshot.viewType.Front, scale / 100, "Front View");
//sheet.Entities.Add(frontView); // <-- make sure this is added to sheet.Views before using it as parent
//designKalipDoc.Viewports.Add(new Viewport());
sheet.AddViewPlaceHolder(frontView, fullDesign, kalipDrawing, "Front View");
designKalipDoc.Entities.Regen();
// Finally rebuild
kalipDrawing.Rebuild(designKalipDoc, false, false);
double midX = (bboxMin.X + bboxMax.X) / 2.0;
double depth = 2.0; // depth in cm
// 2. Compute box size (YZ span)
double width = bboxMax.Y - bboxMin.Y;
double height = bboxMax.Z - bboxMin.Z;
// 3. Create a solid clipping box at midX
Solid clippingBox = Solid.CreateBox(depth, width, height); // Box along X
clippingBox.Translate(midX - depth / 2, bboxMin.Y, bboxMin.Z);
// 4. Intersect all solids in the model with the clipping box
Design clippedDesign = new Design();
foreach (Entity ent in designKalipDoc.Entities)
{
if (ent is Solid solid)
{
var copy = solid.Clone() as Solid;
if (copy == null)
continue;
Solid[] result = Solid.Intersection(copy, clippingBox);
if (result != null && result.Length > 0)
clippedDesign.Entities.AddRange(result);
}
}
clippedDesign.Entities.Regen();
// Define a section line that cuts vertically at the midpoint
double viewWidth = modelWidth * scale;
double viewHeight = modelHeight * scale;
// Section line placed at the vertical mid-span
double sectionX = viewWidth / 2;
Point2D sectionLineP0 = new Point2D(sectionX, 0); // bottom of view
Point2D sectionLineP1 = new Point2D(sectionX, viewHeight); // top of view
// Place SectionView under the FrontView
Point2D sectionViewPosition = new Point2D(centerX, centerY - viewHeight - 5);
// Define the SectionView correctly using parent View
SectionView sectionView = new SectionView(
sectionViewPosition,
frontView,
sectionLineP0,
sectionLineP1,
"Section A-A"
);
clippedDesign.Viewports.Add(new Viewport());
//sheet.Entities.Add(sectionView);
sheet.AddViewPlaceHolder(sectionView, clippedDesign, kalipDrawing, "Section A-A");
kalipDrawing.Rebuild(clippedDesign, false, false);
AddTrussDimension(sheet, scale, modelWidth, modelHeight);
}
Comments
Hi Serkan,
Please open a support ticket and provide a small Visual Studio sample to reproduce the issue.
Please sign in to leave a comment.