1. 程式人生 > 實用技巧 >AnyCAD C#開發-BrepTools::Transform變換移動

AnyCAD C#開發-BrepTools::Transform變換移動

AnyCAD2020+VS2012

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

using AnyCAD.Platform;
using AnyCAD.Exchange;
using AnyCAD.Presentation;

namespace WindowsFormsApplication3
{
    public partial class Form1 : Form
    {
        AnyCAD.Presentation.RenderWindow3d renderView;
        AnyCAD.Platform.BrepTools BrepToolsFeat = new AnyCAD.Platform.BrepTools();
        AnyCAD.Exchange.StepReader reader = new AnyCAD.Exchange.StepReader();

        public Form1()
        {
            InitializeComponent();

            this.renderView = new AnyCAD.Presentation.RenderWindow3d();
            this.Controls.Add(renderView);
            renderView.Size = this.ClientSize;
        }

        TopoShape exrude1;
        TopoShape exrude2;
        private void button1_Click(object sender, EventArgs e)
        {
            //建立橢圓
            TopoShape ellipse1 = BrepToolsFeat.MakeEllipse(new Vector3(0, 0, 0), 60, 40, new Vector3(0, 0, 1));

            //建立一個面
            TopoShape ellipse2 = BrepToolsFeat.MakeEllipse(new Vector3(100, 100, 100), 60, 40, new Vector3(0, 0, 1));
            TopoShape face1 = BrepToolsFeat.MakeFace(ellipse2);

            //建立拉伸
            exrude1 = BrepToolsFeat.Extrude(ellipse1, 100, new Vector3(0, 0, 1));
            exrude2 = BrepToolsFeat.Extrude(face1, 100, new Vector3(0, 0, 1));

            //顯示幾何
            int exrude1ID = 0;
            renderView.ShowGeometry(exrude1, exrude1ID);

            int exrude2ID = 0;
            renderView.ShowGeometry(exrude2, exrude2ID);

        }

        private void button2_Click(object sender, EventArgs e)
        {
            //變換移動
            Coordinate3 coord1 = new Coordinate3(new Vector3(200, 200, 200), new Vector3(1,0,0), new Vector3(0,1,0), new Vector3(0,0,1));
            TopoShape transform1 = BrepToolsFeat.Transform(exrude1, coord1);

            //顯示幾何
            int transform1ID = 0;
            renderView.ShowGeometry(transform1, transform1ID);
        }
    }
}

Caesar盧尚宇
2020年6月29日