UG二次开发 实体转装配零件并将实体属性填写到装配零件中(C#)
2021/11/29 14:07:24
本文主要是介绍UG二次开发 实体转装配零件并将实体属性填写到装配零件中(C#),对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
1 /// <summary> 2 /// 实体转化为装配 3 /// </summary> 4 /// <param name="prtfull">全路径</param> 5 /// <param name="bodys">实体</param> 6 /// <param name="SaveBool">是否保存零件</param> 7 /// <returns>返回prtTag </returns> 8 public void CreatObjPartToAssembly(string prtfull, Body bodys, bool SaveBool, ref Tag prtTag) 9 { 10 NXOpen.FileNew fileNew1; 11 fileNew1 = base.theSession.Parts.FileNew(); 12 fileNew1.TemplateFileName = "model-plain-1-mm-template.prt"; 13 fileNew1.UseBlankTemplate = false; 14 fileNew1.ApplicationName = "ModelTemplate"; 15 fileNew1.Units = NXOpen.Part.Units.Millimeters; 16 fileNew1.RelationType = ""; 17 fileNew1.UsesMasterModel = "No"; 18 fileNew1.TemplateType = NXOpen.FileNewTemplateType.Item; 19 fileNew1.ItemType = ""; 20 fileNew1.Specialization = ""; 21 fileNew1.SetCanCreateAltrep(false); 22 fileNew1.NewFileName = prtfull; 23 fileNew1.MasterFileName = ""; 24 fileNew1.MakeDisplayedPart = false; 25 NXOpen.Assemblies.CreateNewComponentBuilder createNewComponentBuilder1; 26 createNewComponentBuilder1 = workPart.AssemblyManager.CreateNewComponentBuilder(); 27 createNewComponentBuilder1.ReferenceSet = NXOpen.Assemblies.CreateNewComponentBuilder.ComponentReferenceSetType.Other; 28 createNewComponentBuilder1.ReferenceSetName = "PART"; 29 createNewComponentBuilder1.OriginalObjectsDeleted = false; 30 string name = Path.GetFileNameWithoutExtension(prtfull); 31 createNewComponentBuilder1.NewComponentName = name.ToUpper(); 32 bool added1; 33 added1 = createNewComponentBuilder1.ObjectForNewComponent.Add(bodys); 34 createNewComponentBuilder1.NewFile = fileNew1; 35 NXOpen.NXObject nXObject1; 36 nXObject1 = createNewComponentBuilder1.Commit(); 37 Tag occTag = nXObject1.Tag; 38 Tag InstanceTag = theUfSession.Assem.AskInstOfPartOcc(occTag); 39 prtTag = theUfSession.Assem.AskChildOfInstance(InstanceTag); 40 NXOpen.BasePart bpart = (NXOpen.BasePart)NXObjectManager.Get(prtTag); 41 if (SaveBool) 42 { 43 bpart.Save(BasePart.SaveComponents.True, BasePart.CloseAfterSave.False); 44 } 45 NXObject.AttributeInformation[] allAttrs = bodys.GetUserAttributes(); 46 foreach (NXObject.AttributeInformation attrinfo in allAttrs) 47 { 48 bpart.SetUserAttribute(attrinfo, Update.Option.Now); 49 } 50 createNewComponentBuilder1.Destroy(); 51 }
这篇关于UG二次开发 实体转装配零件并将实体属性填写到装配零件中(C#)的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2022-03-01沐雪多租宝商城源码从.NetCore3.1升级到.Net6的步骤
- 2024-11-18微软研究:RAG系统的四个层次提升理解与回答能力
- 2024-11-15C#中怎么从PEM格式的证书中提取公钥?-icode9专业技术文章分享
- 2024-11-14云架构设计——如何用diagrams.net绘制专业的AWS架构图?
- 2024-05-08首个适配Visual Studio平台的国产智能编程助手CodeGeeX正式上线!C#程序员必备效率神器!
- 2024-03-30C#设计模式之十六迭代器模式(Iterator Pattern)【行为型】
- 2024-03-29c# datetime tryparse
- 2024-02-21list find index c#
- 2024-01-24convert toint32 c#
- 2024-01-24Advanced .Net Debugging 1:你必须知道的调试工具