首页 > 代码库 > 基于Composer Player 模型加载和相关属性设置
基于Composer Player 模型加载和相关属性设置
主要是基于达索软件Composer Player、的基础上做些二次开发。
public class ComposerToolBarSetting { public bool AntiAliasingOnIdle { get; set; }//抗锯齿化 public bool AssySelectionMode { get; set; }//使能选择装配树 public bool AssySelectionModeViewportIndicator { get; set; }//装配树选择模式 public bool AutoKeyMode { get; set; }//使能自动键 public bool AutoPlay { get; set; } //自动播放 public bool BorderMask { get; set; }//在控件窗体应用border public bool CameraInertia { get; set; }//照相机惯性模式 public bool CameraPlayMode { get; set; }//照相机播放模式 public bool GroundGrid { get; set; }//地面 public bool LoopPlay { get; set; }//循环播放 public bool NoHighlight { get; set; }//高亮显示 public bool RemoveMeasurementCommands { get; set; }//移除测量工具条 public bool RenderGroundShadow { get; set; }//渲染地面阴影 public bool ShowAnnotationToolBar { get; set; }//注释工具条 public bool ShowAssemblyTreeBar { get; set; }//装配树 public bool ShowBomTreeBar { get; set; }//BOM树 public bool ShowCameraToolBar { get; set; }//照相机工具条 public bool ShowCameraViewToolBar { get; set; }//照相机视图工具条 public bool ShowCollabToolBar { get; set; }//协同工具条 public bool ShowCollabTreeBar { get; set; }//协同树 public bool ShowCuttingPlaneToolBar { get; set; }//剖切工具条 public bool ShowGeometryToolBar { get; set; }//几何图形工具条 public bool ShowMain3DToolBar { get; set; }//主要3D工具条 public bool ShowMarkerBar { get; set; }//标记工具条 public bool ShowMeasurementToolBar { get; set; }//测量工具条 public bool ShowPaper { get; set; }//显示白纸页面 public bool ShowPropertyBar { get; set; }//属性 public bool ShowRedlineToolBar { get; set; }//红线工具条 public bool ShowRenderToolBar { get; set; }//渲染工具条 public bool ShowStandardToolBar { get; set; }//标准工具条 public bool ShowStatusBar { get; set; }//状态条 public bool ShowTimelineBar { get; set; }//时间线 public bool ShowTreesBar { get; set; }//树 public bool ShowViewBar { get; set; }//视图条 public bool ShowVisibilityToolBar { get; set; }//可见性工具条 public bool UseGUID { get; set; }//是否返回GUID }
public class ComposerManager { /// <summary> /// 设置控件的属性 /// </summary> /// <param name="player">控件的名字</param> public static void SetComposerPlayerToolsBar(AxDS3DVIAPlayerActiveXLib.AxDS3DVIAPlayerActiveX player) { player.AntiAliasingOnIdle = GetCompserPlayerToolBar().AntiAliasingOnIdle; player.AssySelectionMode = GetCompserPlayerToolBar().AssySelectionMode; player.AssySelectionModeViewportIndicator = GetCompserPlayerToolBar().AssySelectionModeViewportIndicator; player.AutoKeyMode = GetCompserPlayerToolBar().AutoKeyMode; player.AutoPlay = GetCompserPlayerToolBar().AutoPlay; player.BorderMask = GetCompserPlayerToolBar().BorderMask; player.CameraInertia = GetCompserPlayerToolBar().CameraInertia; player.CameraPlayMode = GetCompserPlayerToolBar().CameraPlayMode; player.GroundGrid = GetCompserPlayerToolBar().GroundGrid; player.LoopPlay = GetCompserPlayerToolBar().LoopPlay; player.NoHighlight = GetCompserPlayerToolBar().NoHighlight; player.RemoveMeasurementCommands = GetCompserPlayerToolBar().RemoveMeasurementCommands; player.RenderGroundShadow = GetCompserPlayerToolBar().RenderGroundShadow; player.ShowAnnotationToolBar = GetCompserPlayerToolBar().ShowAnnotationToolBar; player.ShowAssemblyTreeBar = GetCompserPlayerToolBar().ShowAssemblyTreeBar; player.ShowBOMTreeBar = GetCompserPlayerToolBar().ShowBomTreeBar; player.ShowCameraToolBar = GetCompserPlayerToolBar().ShowCameraToolBar; player.ShowCameraViewToolBar = GetCompserPlayerToolBar().ShowCameraViewToolBar; player.ShowCollabToolBar = GetCompserPlayerToolBar().ShowCollabToolBar; player.ShowCollabTreeBar = GetCompserPlayerToolBar().ShowCollabTreeBar; player.ShowCuttingPlaneToolBar = GetCompserPlayerToolBar().ShowCuttingPlaneToolBar; player.ShowGeometryToolBar = GetCompserPlayerToolBar().ShowGeometryToolBar; player.ShowMain3DToolBar = GetCompserPlayerToolBar().ShowMain3DToolBar; player.ShowMarkerBar = GetCompserPlayerToolBar().ShowMarkerBar; player.ShowMeasurementToolBar = GetCompserPlayerToolBar().ShowMeasurementToolBar; player.ShowPaper = GetCompserPlayerToolBar().ShowPaper; player.ShowPropertyBar = GetCompserPlayerToolBar().ShowPropertyBar; player.ShowRedlineToolBar = GetCompserPlayerToolBar().ShowRedlineToolBar; player.ShowRenderToolBar = GetCompserPlayerToolBar().ShowRenderToolBar; player.ShowStandardToolBar = GetCompserPlayerToolBar().ShowStandardToolBar; player.ShowStatusBar = GetCompserPlayerToolBar().ShowStatusBar; player.ShowTimelineBar = GetCompserPlayerToolBar().ShowTimelineBar; player.ShowTreesBar = GetCompserPlayerToolBar().ShowTreesBar; player.ShowViewBar = GetCompserPlayerToolBar().ShowViewBar; player.ShowVisibilityToolBar = GetCompserPlayerToolBar().ShowVisibilityToolBar; player.UseGUID = GetCompserPlayerToolBar().UseGUID; } /// <summary> /// 将字符类型转化为Boolen类型 /// </summary> /// <param name="str"></param> /// <returns></returns> static bool StringToBool(string str) { bool result = false; if (str != null) { if (str == "false") { result = false; } else if (str == "true") { result = true; } } return result; } /// <summary> /// 将Boolen类型转化为字符类型 /// </summary> /// <param name="result"></param> /// <returns></returns> static string BoolToString(bool result) { string str = ""; if (result) { str = "true"; } else { str = "false"; } return str; } /// <summary> /// 读取app.config里的key对应的值,并赋值给ComposerToolBarSetting类 /// </summary> /// <returns></returns> public static ComposerToolBarSetting GetCompserPlayerToolBar() { ComposerToolBarSetting set = new ComposerToolBarSetting(); set.AntiAliasingOnIdle = StringToBool(AppConfigManager.GetValue("AntiAliasingOnIdle", ConfigFileType.AppConfig)); set.AssySelectionMode=StringToBool(AppConfigManager.GetValue("AssySelectionMode",ConfigFileType.AppConfig)); set.AssySelectionModeViewportIndicator = StringToBool(AppConfigManager.GetValue("AssySelectionModeViewportIndicator", ConfigFileType.AppConfig)); set.AutoKeyMode = StringToBool(AppConfigManager.GetValue("AutoKeyMode", ConfigFileType.AppConfig)); set.AutoPlay = StringToBool(AppConfigManager.GetValue("AutoPlay", ConfigFileType.AppConfig)); set.BorderMask = StringToBool(AppConfigManager.GetValue("BorderMask", ConfigFileType.AppConfig)); set.CameraInertia = StringToBool(AppConfigManager.GetValue("CameraInertia", ConfigFileType.AppConfig)); set.CameraPlayMode = StringToBool(AppConfigManager.GetValue("CameraPlayMode", ConfigFileType.AppConfig)); set.GroundGrid = StringToBool(AppConfigManager.GetValue("GroundGrid", ConfigFileType.AppConfig)); set.LoopPlay = StringToBool(AppConfigManager.GetValue("LoopPlay", ConfigFileType.AppConfig)); set.NoHighlight = StringToBool(AppConfigManager.GetValue("NoHighlight", ConfigFileType.AppConfig)); set.RemoveMeasurementCommands = StringToBool(AppConfigManager.GetValue("RemoveMeasurementCommands", ConfigFileType.AppConfig)); set.RenderGroundShadow = StringToBool(AppConfigManager.GetValue("RenderGroundShadow", ConfigFileType.AppConfig)); set.ShowAnnotationToolBar = StringToBool(AppConfigManager.GetValue("ShowAnnotationToolBar", ConfigFileType.AppConfig)); set.ShowAssemblyTreeBar = StringToBool(AppConfigManager.GetValue("ShowAssemblyTreeBar", ConfigFileType.AppConfig)); set.ShowBomTreeBar = StringToBool(AppConfigManager.GetValue("ShowBOMTreeBar", ConfigFileType.AppConfig)); set.ShowCameraToolBar = StringToBool(AppConfigManager.GetValue("ShowCameraToolBar", ConfigFileType.AppConfig)); set.ShowCameraViewToolBar = StringToBool(AppConfigManager.GetValue("ShowCameraViewToolBar", ConfigFileType.AppConfig)); set.ShowCollabToolBar = StringToBool(AppConfigManager.GetValue("ShowCollabToolBar", ConfigFileType.AppConfig)); set.ShowCollabTreeBar = StringToBool(AppConfigManager.GetValue("ShowCollabTreeBar", ConfigFileType.AppConfig)); set.ShowCuttingPlaneToolBar = StringToBool(AppConfigManager.GetValue("ShowCuttingPlaneToolBar", ConfigFileType.AppConfig)); set.ShowGeometryToolBar = StringToBool(AppConfigManager.GetValue("ShowGeometryToolBar", ConfigFileType.AppConfig)); set.ShowMain3DToolBar = StringToBool(AppConfigManager.GetValue("ShowMain3DToolBar", ConfigFileType.AppConfig)); set.ShowMarkerBar = StringToBool(AppConfigManager.GetValue("ShowMarkerBar", ConfigFileType.AppConfig)); set.ShowMeasurementToolBar = StringToBool(AppConfigManager.GetValue("ShowMeasurementToolBar", ConfigFileType.AppConfig)); set.ShowPaper = StringToBool(AppConfigManager.GetValue("ShowPaper", ConfigFileType.AppConfig)); set.ShowPropertyBar = StringToBool(AppConfigManager.GetValue("ShowPropertyBar", ConfigFileType.AppConfig)); set.ShowRedlineToolBar = StringToBool(AppConfigManager.GetValue("ShowRedlineToolBar", ConfigFileType.AppConfig)); set.ShowRenderToolBar = StringToBool(AppConfigManager.GetValue("ShowRenderToolBar", ConfigFileType.AppConfig)); set.ShowStandardToolBar = StringToBool(AppConfigManager.GetValue("ShowStandardToolBar", ConfigFileType.AppConfig)); set.ShowStatusBar = StringToBool(AppConfigManager.GetValue("ShowStatusBar", ConfigFileType.AppConfig)); set.ShowTimelineBar = StringToBool(AppConfigManager.GetValue("ShowTimelineBar", ConfigFileType.AppConfig)); set.ShowTreesBar = StringToBool(AppConfigManager.GetValue("ShowTreesBar", ConfigFileType.AppConfig)); set.ShowViewBar = StringToBool(AppConfigManager.GetValue("ShowViewBar", ConfigFileType.AppConfig)); set.ShowVisibilityToolBar = StringToBool(AppConfigManager.GetValue("ShowVisibilityToolBar", ConfigFileType.AppConfig)); set.UseGUID = StringToBool(AppConfigManager.GetValue("UseGUID", ConfigFileType.AppConfig)); return set; } }
public class ComposerTreeView { //建立xml的路径 string xmlpath = AppDomain.CurrentDomain.BaseDirectory + "21.Xml"; //判断字符是否为中文 static bool IsChinese(string CString) { return Regex.IsMatch(CString, @"^[\u4e00-\u9fa5]+$"); } /// <summary> /// 创建头结点和下一级节点 /// </summary> /// <param name="player">控件的名称</param> /// <param name="treeview">TreeView的名字</param> public static void CreateFirstNode(AxDS3DVIAPlayerActiveXLib.AxDS3DVIAPlayerActiveX player,TreeView treeview) { var rnode = new TreeNode(); string rootstr = player.GetAssyRoot(); string[] RArray = rootstr.Split(‘"‘); foreach (var item in RArray) { if ( item.Length == 2 && IsChinese(item) ) { TreeNode node = new TreeNode(); node.Text = item; rnode.Nodes.Add(node); } } treeview.Nodes.Add(rnode); } /// <summary> /// 建立xml信息 /// </summary> /// <param name="xmlname">xml文件的名字</param> private void FillXml(string xmlname) { if (File.Exists(xmlpath)) { File.Delete(xmlpath); } XElement root = XElement.Parse(xmlname); root.Save(xmlpath); } /// <summary> /// 将子节点添加到父节点 /// </summary> /// <param name="tnode">子节点</param> /// <param name="parentnode">父节点</param> private void addTreeNode(TreeNode tnode, TreeNode parentnode) { parentnode.Nodes.Add(tnode); } List<TreeNode> nodelist = new List<TreeNode>(); /// <summary> ///返回选中节点下的子节点名字集合 /// </summary> /// <param name="player">控件的名字</param> /// <param name="treeview">TreeView的名字</param> /// <returns></returns> private List<TreeNode> createTreeNode(AxDS3DVIAPlayerActiveXLib.AxDS3DVIAPlayerActiveX player, TreeView treeview) { List<string> childlist = new List<string>(); string childname = treeview.SelectedNode.Text; if (childname != null) { string childrenstr = player.GetAssyChild(CLitSelectionName(childname)); FillXml(childrenstr); XDocument doc = XDocument.Load(xmlpath); var query = from fx in doc.Descendants("CLitModifiable") select new { NodeName = fx.Attribute("Name").Value }; foreach (var item in query) { TreeNode node1 = new TreeNode(); node1.Text = item.NodeName; if (!nodelist.Contains(node1)) { nodelist.Add(node1); } } } return nodelist; } /// <summary> /// 准备好选择对象的字符串 /// </summary> /// <param name="name">指定对象的名字</param> /// <returns></returns> static string CLitSelectionName(string name) { return "<CLitSelection Name=‘‘ ><CLitModifiable Name=‘" + name + "‘/></CLitSelection>"; } /// <summary> /// 根据点击选择的节点,查询出其下面的子节点信息 /// </summary> /// <param name="player"></param> /// <param name="treeview"></param> public void TreeViewAfterSelect(AxDS3DVIAPlayerActiveXLib.AxDS3DVIAPlayerActiveX player, TreeView treeview) { nodelist.Clear(); nodelist = createTreeNode(player, treeview); var parent = from fx in nodelist select fx; treeview.SelectedNode.Nodes.Clear(); foreach (var item in parent) { TreeNode node = new TreeNode(); node.Text = item.Text; if (!treeview.SelectedNode.Nodes.Contains(node)) { treeview.SelectedNode.Nodes.Add(node); } } treeview.ExpandAll(); } }
基于Composer Player 模型加载和相关属性设置
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。