First thing to know is that there can be many MCS in a part, and you need to make one of them the active MCS. This requires being in the Manufacturing Applicaiton, and selecting or editing the mill_orient group, or one of the child operations.
This is what I would do interactively. You could do the same thing:
it's a good idea ,but i must to edit a operation or MCS for changing the WCS , select is not enough.
I am going to try to think every time of putting my wcs on my MCS.
I thought that it was easier than that !!
I finally found a solution.
From a character string, i create a 3D point which is related to my WCS
If anyone is interested, my code below.( i'm not a programmer ,there is certainly a more effective solution)
Thanks for this amazing website : http://www.nxjournaling.com/
Option Strict Off Imports System Imports NXOpen Imports NXOpen.UF Module GOTOPoint Dim ufs As UFSession = UFSession.GetUFSession() Sub Main() Dim theSession As Session = Session.GetSession() Dim workPart As Part = theSession.Parts.Work Dim lw As ListingWindow = theSession.ListingWindow Dim goto_point As String = InputBox("GOTO/:", "Coordonnées") Dim words = goto_point.Split(","c) Dim gotox = val(words(words.length - 3)) Dim gotoy = val(words(words.length - 2)) Dim gotoz = val(words(words.length - 1)) Dim lenght_goto As Integer = words.length If goto_point = "" Then MsgBox("GOTO Annulé!", MsgBoxStyle.Exclamation, "Erreur") Exit Sub End If If lenght_goto > 3 Then MsgBox("Trop de valeurs sur le GOTO", MsgBoxStyle.Exclamation, "Erreur") Exit Sub End If lw.Open()
REM Création Point3d Dim Pt As New Point3d Pt.X = gotox Pt.Y = gotoy Pt.Z = gotoz REM Création point -> WCS Dim ptObj As Point Dim originwcs As NXOpen.Point3d originwcs = WCS2Abs(Pt) ptObj = workPart.Points.CreatePoint(originwcs) ptObj.SetVisibility(SmartObject.VisibilityOption.V
isible) lw.WriteLine("GOTO/" & goto_point) lw.WriteLine("X=" & gotox) lw.WriteLine("Y=" & gotoy) lw.WriteLine("Z=" & gotoz) lw.Close() End Sub Function WCS2Abs(ByVal inPt As Point3d) As Point3d Dim pt1(2), pt2(2) As Double pt1(0) = inPt.X pt1(1) = inPt.Y pt1(2) = inPt.Z ufs.Csys.MapPoint(UFConstants.UF_CSYS_ROOT_WCS_COO RDS, pt1, _ UFConstants.UF_CSYS_ROOT_COORDS, pt2) WCS2Abs.X = pt2(0) WCS2Abs.Y = pt2(1) WCS2Abs.Z = pt2(2) End Function Public Function GetUnloadOption(ByVal dummy As String) As Integer 'Unloads the image when the NX session terminates GetUnloadOption = NXOpen.Session.LibraryUnloadOption.AtTermination End Function End Module