当前位置:网站首页>WPF 3D application building (Foundation)
WPF 3D application building (Foundation)
2022-07-19 08:33:00 【Persistent Tao】
1 Create project
Choose to create WPF application

Give the program a cool name , Choose a cool location :

Choose .NET6

2 Configuration items
from nuget.org Installation on AnyCAD Rapid SDK 2022.

3 Design interface
- First introduce the assembly :
xmlns:anycad="clr-namespace:AnyCAD.WPF;assembly=AnyCAD.WPF.NET6"
- Design layout
Leave a place for the three-dimensional interface , Classic left and right windows . The right side is used to display three-dimensional content . complete xaml as follows :
<Window x:Class="WpfApp1.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:WpfApp1"
xmlns:anycad="clr-namespace:AnyCAD.WPF;assembly=AnyCAD.WPF.NET6"
mc:Ignorable="d"
Title="MainWindow" Height="450" Width="800">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition MinWidth="100" Width="0.3*"/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<anycad:RenderControl Grid.Column="1" x:Name="mRenderCtrl"/>
</Grid>
</Window> Run it :

5 According to the model
- Add one more ViewerReady event

<anycad:RenderControl Grid.Column="1" x:Name="mRenderCtrl" ViewerReady="mRenderCtrl_ViewerReady"/>- stay mRenderCtrl_ViewerReady Create a ball in
private void mRenderCtrl_ViewerReady()
{
var shape = ShapeBuilder.MakeSphere(new GPnt(0, 0, 0), 100);
mRenderCtrl.ShowShape(shape, ColorTable.AliceBlue);
}You cannot operate the 3D control until the initialization of the control is completed
Run it again :

6 Release resources
In debug mode , When the program exits, it is in the output window , You may find such a mistake :
Program “[57196] WpfApp1.exe” Exited , The return value is 3221225477 (0xc0000005) 'Access violation'.
This is because AnyCAD Rapid SDK Not releasing resources correctly . To ensure that 3D control resources can be released correctly , The program can get the normal return value , Just add it like this Startup and Exit news :
<Application x:Class="WpfApp1.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:WpfApp1"
StartupUri="MainWindow.xaml" Exit="Application_Exit" Startup="Application_Startup">
<Application.Resources>
</Application.Resources>
</Application>Code changes :
public partial class App : Application
{
private void Application_Startup(object sender, StartupEventArgs e)
{
AnyCAD.Foundation.GlobalInstance.Initialize();
}
private void Application_Exit(object sender, ExitEventArgs e)
{
AnyCAD.Foundation.GlobalInstance.Destroy();
}
}边栏推荐
- 6-9 vulnerability exploitation telnet login rights lifting
- 5.1 安全漏洞與防範
- 812. Maximum triangle area
- 60、wsgiref手写web框架+jinja2模块初识
- Talk about distributed locks
- matlab导入小数点后9位以上的浮点数
- Great summary! Finally, someone explained all kinds of SQL join connections clearly
- 5.1 security vulnerabilities and Prevention
- How to select MCU?
- 力扣43字符串相乘笔记
猜你喜欢
随机推荐
SPARK中的FileSourceStrategy,DataSourceStrategy以及DataSourceV2Strategy
Use of OpenCV polar transformation function warppolar
rosbridge
JS学习笔记01-03——this的引用,全局作用域,方法
OpenCV极坐标转换函数warpPolar的使用
No module named 'yaml' solution
trochvision中数据集的使用
matlab导入小数点后9位以上的浮点数
畅玩JVM——关于GC垃圾回收必须要掌握的知识
JS learning notes 14-15: JS array and array letter quantity
Sword finger offer 42 Maximum sum dynamic programming method for continuous subarrays
Deep learning 7 deep feedforward network
Gateway new generation gateway
深度学习第一周Introduction to Deep Learning习题整理
《Flutter入门》flutter计算最近1个月、3个月、半年、12个月
5g at that time, where will driverless driving go in the future?
65. Restful specification
Wvppro-zlm-gb21818-camera
Seaport 以及 ERC-4907 能否成为释放NFT流动性的新途径?| Tokenview
oop_ Reference type variable transfer value










