NXOpen.UF.UFSession theufsession = NXOpen.UF.UFSession.GetUFSession (); try {//initialize NXOpen.UF.UFClone.OperationClass Operationclass = Nxopen. UF. UFClone.OperationClass.CloneOperation; TheUfSession.Clone.Initialise (Operationclass); Add the original assembly to the clone assembly, there are add Assembly and add Part two methods, here with the add Assembly NXOpen.UF.UFPart.LoadStatus loadstatus; theUfSession.Clone.AddAssembly (Selectpath,out loadstatus); TheUfSession.Clone.AddPart (Selectpath); Specifies the default clone mode NXOpen.UF.UFClone.Action Action = NXOpen.UF.UFClone.Action.Clone; TheUfSession.Clone.SetDefAction (action); Method for specifying a default file name NXOpen.UF.UFClone.NamingTechnique Namingtechnique = NXOpen.UF.UFClone.NamingTechnique.Nami Ngrule; TheUfSession.Clone.SetDefNaming (Namingtechnique); Define clone naming rules for new assemblies NXOpen.UF.UFClone.NameRuleDef Nameruledef; Nameruledef.type = UFClone.NameRuleType.PrependString; nameruledef.new_string = "M8"; nameruledef.base_string = ""; Before the NX7.5 version, the following sentence is not required, but is called in later versions of NX7.5, you must add the following sentence, otherwise the cloning error will be displayed. NXOpen.UF.UFClone.NamingFailures Namingfailures; TheUfSession.Clone.InitNamingFailures (out namingfailures); TheUfSession.Clone.SetNameRule (ref nameruledef, ref namingfailures); TheUfSession.Clone.SetDefDirectory (@ "C:\temp\"); String outputname = "C:\\xxxxx.prt"; TheUfSession.Clone.SetNaming (Selectpath, UFClone.NamingTechnique.DefaultNaming, outputname); TheUI.NXMessageBox.Show ("", NXMessageBox.DialogType.Information, Namingfailures.n_failures. ToString ()); TheUfSession.Clone.PerformClone (ref namingfailures);TheUfSession.Clone.Terminate (); } catch (Exception Ex1) {theUI.NXMessageBox.Show ("Block Styler", Nxmessa GeBox.DialogType.Error, Ex1. ToString ()); } finally {theUfSession.Clone.Terminate (); }
NX Two-time development clones