Option Strict Off
Imports System
Imports NXOpen
Imports System.IO
Imports System.Math
Imports NXOpen.UF
Imports NXOpen.ASSEMBLIES
Imports NXOpen.Utilities
Imports System.Windows.Forms
Imports System.Runtime.InteropServices
'- - - - - - - - - - - - - - - - - - - - - -
Module NXJournal
Public Ses As Session = Session.GetSession()
Public UISes As UI = UI.GetUI()
Public UFSes As UFSession = UFSession.GetUFSession()
Public workPart As NXOpen.Part = Ses.Parts.Work
Public dp As Part = Ses.Parts.Display
Public msg As NXMessageBox = UI.GetUI().NXMessageBox
Public Class JournalDialog
Inherits System.Windows.Forms.Form
Dim UFSes As UFSession = UFSession.GetUFSession()
Public Sub New()
MyBase.New()
' The Me.InitializeComponent call is required for Windows Forms designer support.
Me.InitializeComponent()
'
' TODO : Add constructor code after InitializeComponents
'
Dim xPos, yPos As Short
UFSes.Ui.GetDa1Coords(xPos, yPos)
NXOpenUI.FormUtilities.ReparentForm(Me)
NXOpenUI.FormUtilities.SetApplicationIcon(Me)
Me.Location = New System.Drawing.Point(CType(xPos, Integer), CType(yPos, Integer))
End Sub
''' <summary>
''' Designer variable used to keep track of non-visual components.
''' </summary>
Private components As System.ComponentModel.IContainer
''' <summary>
''' Disposes resources used by the form.
''' </summary>
''' <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
Protected Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
''' <summary>
''' This method is required for Windows Forms designer support.
''' Do not change the method contents inside the source code editor. The Forms designer might
''' not be able to load this method if it was changed manually.
''' </summary>
Private Sub InitializeComponent()
Me.label1 = New System.Windows.Forms.Label
Me.label2 = New System.Windows.Forms.Label
Me.Felfogas = New System.Windows.Forms.TextBox
Me.Szikrakoz = New System.Windows.Forms.TextBox
Me.buttonCancel = New System.Windows.Forms.Button
Me.buttonOK = New System.Windows.Forms.Button
Me.SuspendLayout
'
'label1
'
Me.label1.FlatStyle = System.Windows.Forms.FlatStyle.System
Me.label1.Location = New System.Drawing.Point(21, 19)
Me.label1.Name = "label1"
Me.label1.Size = New System.Drawing.Size(147, 24)
Me.label1.TabIndex = 0
Me.label1.Text = "Felfogas szama"
'
'label2
'
Me.label2.FlatStyle = System.Windows.Forms.FlatStyle.System
Me.label2.Location = New System.Drawing.Point(21, 49)
Me.label2.Name = "label2"
Me.label2.Size = New System.Drawing.Size(147, 24)
Me.label2.TabIndex = 1
Me.label2.Text = "Szikrakoz"
'
'
'Felfogas
'
Me.Felfogas.Location = New System.Drawing.Point(174, 16)
Me.Felfogas.Name = "setup"
Me.Felfogas.Size = New System.Drawing.Size(100, 20)
Me.Felfogas.TabIndex = 4
Me.Felfogas.Text = "1"
Me.Felfogas.TextAlign = System.Windows.Forms.HorizontalAlignment.Right
'
'Szikrakoz
'
Me.Szikrakoz.Location = New System.Drawing.Point(174, 46)
Me.Szikrakoz.Name = "Spark"
Me.Szikrakoz.Size = New System.Drawing.Size(100, 20)
Me.Szikrakoz.TabIndex = 5
Me.Szikrakoz.Text = "0.2"
Me.Szikrakoz.TextAlign = System.Windows.Forms.HorizontalAlignment.Right
'
'buttonCancel
'
Me.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel
Me.buttonCancel.FlatStyle = System.Windows.Forms.FlatStyle.System
Me.buttonCancel.Location = New System.Drawing.Point(49, 77)
Me.buttonCancel.Name = "buttonCancel"
Me.buttonCancel.Size = New System.Drawing.Size(75, 23)
Me.buttonCancel.TabIndex = 8
Me.buttonCancel.Text = "Cancel"
'
'buttonOK
'
Me.buttonOK.DialogResult = System.Windows.Forms.DialogResult.OK
Me.buttonOK.FlatStyle = System.Windows.Forms.FlatStyle.System
Me.buttonOK.Location = New System.Drawing.Point(174, 77)
Me.buttonOK.Name = "buttonOK"
Me.buttonOK.Size = New System.Drawing.Size(75, 23)
Me.buttonOK.TabIndex = 9
Me.buttonOK.Text = "OK"
'
'JournalDialog
'
Me.AcceptButton = Me.buttonOK
Me.CancelButton = Me.buttonCancel
Me.ClientSize = New System.Drawing.Size(301, 107)
Me.Controls.Add(Me.buttonOK)
Me.Controls.Add(Me.buttonCancel)
Me.Controls.Add(Me.Szikrakoz)
Me.Controls.Add(Me.Felfogas)
Me.Controls.Add(Me.label2)
Me.Controls.Add(Me.label1)
Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog
Me.MaximizeBox = false
Me.MinimizeBox = false
Me.Name = "JournalDialog"
Me.Text = "Rohteil"
Me.TopMost = true
Me.ResumeLayout(false)
Me.PerformLayout
End Sub
Private buttonOK As System.Windows.Forms.Button
Private buttonCancel As System.Windows.Forms.Button
Private Szikrakoz As System.Windows.Forms.TextBox
Private Felfogas As System.Windows.Forms.TextBox
Private label2 As System.Windows.Forms.Label
Private label1 As System.Windows.Forms.Label
Public Function GetFelfogasSzama() As Double
Dim Value As String = Me.Felfogas.Text
If String.IsNullOrEmpty(Value) Then Value = "0.0"
Return CDbl(Value)
End Function
Public Function GetSzikrakozErtek() As Double
Dim Value As String = Me.Szikrakoz.Text
If String.IsNullOrEmpty(Value) Then Value = "0.0"
Return CDbl(Value)
End Function
Public Function GetSzikrakozString() As String
Dim SzkString As String = Me.Szikrakoz.Text
If String.IsNullOrEmpty(SzkString) Then SzkString = "0.0"
Return SzkString
End Function
End Class
'=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#
'=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#
'=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#
Sub Main()
Ses.ListingWindow.Open
Ses.ListingWindow.WriteLine("________ujra_______" )
Dim WpSolidsNo as integer = 0
Dim WpVisibleSolidsNo as integer = 0
Dim currprt as String = Ses.Parts.Work.FullPath
Dim currprt_FullPathWoutExt as string = Left$(currprt, InStrRev(currprt, ".") -1 ) 'find last dot, and trim
Dim E_file_name as string = Right$(currprt_FullPathWoutExt, ( Len(currprt_FullPathWoutExt) - InStrRev(currprt_FullPathWoutExt, "\")) )
Dim MarkId As Session.UndoMarkId
Dim Neighbourfacetype As Integer = Nothing
Dim facetype As Integer = Nothing
Dim kerulet as Double
Dim Xdirection , Zdirection as Direction
Dim Oldalelhossz as Double = 0
Dim Vizsgalt_elhossz as Double = 0
Dim pointPos as Integer 'pont ellenorzesehez, hogy kivul van-e a testen
Dim XVector(2), ZVector(2), YVector(2), BasePoint(2), ZplusdirPoint(2), CenterPoint(2) As Double
Dim E_solidbody As Body
Dim pnt As Point3d
'defaults
XVector(0) = 1.0
XVector(1) = 0.0
XVector(2) = 0.0
YVector(0) = 0.0
YVector(1) = 1.0
YVector(2) = 0.0
ZVector(0) = 0.0
ZVector(1) = 0.0
ZVector(2) = 1.0
BasePoint(0) = 0.0
BasePoint(1) = 0.0
BasePoint(2) = 0.0
ZplusdirPoint (0) = 0.0
ZplusdirPoint (1) = 0.0
ZplusdirPoint (2) = 1.0
If (dp Is Nothing) Then
msg.Show("", NXOpen.NXMessageBox.DialogType.Error, "No Display Part !")
Return
End If
'szamlaljuk meg a testeket
For Each aBody As Body In workPart.Bodies
If aBody.IsSolidBody = True Then
WpSolidsNo +=1
If NOT aBody.IsBlanked Then 'if visible solidbody
WpVisibleSolidsNo +=1
End If
End If
Next
'Ses.ListingWindow.WriteLine("solids: " & WpSolidsNo & ", visible of them: " & WpVisibleSolidsNo)
If WpSolidsNo = 0 Then
MsgBox( "no Solids in part" )
Return
Else If WpSolidsNo >1 Then
If WpVisibleSolidsNo > 1
'ha tobb lathato solid van...
UISes.SelectionManager.SelectObject("i have found more solids", "select electrode", Selection.SelectionScope.WorkPart, False, False, E_solidbody, pnt)
Else
For Each bBody As Body In workPart.Bodies
If bBody.IsBlanked = False Then
E_solidbody =bBody
End If
Next
End If
Else If WpSolidsNo = 1 Then
For Each cBody As Body In workPart.Bodies
If cBody.IsBlanked = True Then
cBody.Unblank
End If
E_solidbody = cBody
Next
End If
'Ses.ListingWindow.WriteLine(E_solidbody.Name )
For Each aFace As Face In E_solidbody.GetFaces
UFSes.Modl.AskFaceType(aFace.Tag, facetype)
If facetype = 16 Then 'if cylindrical face
For Each aEdge As Edge In aFace.GetEdges
kerulet = Math.Round((aEdge.GetLength()),6)
If kerulet = Math.Round((UFConstants.PI * 20),6) Then 'and the edge length = 20pi then
For Each NeighbourFace as face In aEdge.GetFaces 'get edge parents
UFSes.Modl.AskFaceType(NeighbourFace.Tag, Neighbourfacetype)
Dim NeighbourFaceEdges() As Edge = NeighbourFace.GetEdges() 'get parents' edges
'If (Neighbourfacetype = 22) & (NeighbourFaceEdges.GetUpperBound(0) > 2) Then
If (Neighbourfacetype = 22) Then 'if the face next to the cylinder is planar
If NeighbourFaceEdges.GetUpperBound(0) > 2 Then 'and has more than 3 boundary edges
BasePoint = get_edge_center(aEdge)
XVector = get_longest_edge_vec(NeighbourFaceEdges)
Else
ZplusdirPoint = get_edge_center(aEdge)
End if
End if
Next
End If
Next
End If
Next
UFSes.Vec3.Sub(ZplusdirPoint, BasePoint, ZVector )
YVector(0) = (ZVector(1) * XVector(2) - ZVector(2) * XVector(1))
YVector(1) = (ZVector(2) * XVector(0) - ZVector(0) * XVector(2))
YVector(2) = (ZVector(0) * XVector(1) - ZVector(1) * XVector(0))
Dim mtx As NXOpen.Tag = NXOpen.Tag.Null
Dim new_csys As NXOpen.Tag = NXOpen.Tag.Null
Dim mtx_vals(8) As Double
ufses.Mtx3.Initialize(XVector, YVector, mtx_vals)
'=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
'=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
'MEASURE Electrode height
' Darab magassaganak meghatarozasa:
' eltolt sik letrehozasa mereshez
' meres
'=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Dim tPlane as tag
tPlane = tag.Null
Dim dPoint(2), dDirection(2) As Double
Dim szorzo as Double = 1000
dpoint(0) = Basepoint(0) + szorzo * Zvector(0)
dpoint(1) = Basepoint(1) + szorzo * Zvector(1)
dpoint(2) = Basepoint(2) + szorzo * Zvector(2)
Dim Zvectorlength as Double = Sqrt(Zvector(0)*Zvector(0)+Zvector(1)*Zvector(1)+Zvector(2)*Zvector(2) )
dDirection(0)= Zvector(0)/ Zvectorlength
dDirection(1)= Zvector(1)/ Zvectorlength
dDirection(2)= Zvector(2)/ Zvectorlength
MarkID = ses.SetUndoMark(Session.MarkVisibility.Invisible, "Datum Plane")
ufses.Modl.CreateFixedDplane(dPoint, dDirection, tPlane)
Dim selpnt(1) As Point3d
Dim dist, accu, magassag As Double
dist = ses.Measurement.GetMinimumDistance(E_solidbody, NXObjectManager.Get(tPlane), selpnt(0), selpnt(1), accu)
Ses.UpdateManager.AddToDeleteList( NXObjectManager.Get(tPlane) )
Ses.UpdateManager.DoUpdate(MarkID)
Ses.DeleteUndoMark(MarkID, "Datum Plane")
magassag = szorzo-dist
'=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
'=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Dim MachiningZero(2) As Double
MachiningZero(0)= Basepoint(0)+ magassag * dDirection(0)
MachiningZero(1)= Basepoint(1)+ magassag * dDirection(1)
MachiningZero(2)= Basepoint(2)+ magassag * dDirection(2)
ufses.Csys.CreateMatrix(mtx_vals, mtx)
ufses.Csys.CreateCsys(MachiningZero, mtx, new_csys)
'Tudjuk:
'elektroda file: E_file_name
'solidbody: E_solidbody
'eltolas: MachiningZero
'Orientacio: mtx
'=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
'parent prt letrehozasa marashoz, pozicionalas: MachiningZero a 0,0,0-ba
'=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Try
Dim MyForm As New JournalDialog
MyForm.Text = "Elektrodamaras"
Dim dFelfogasSzama, dSzikrakozErtek As Double
Try
If MyForm.ShowDialog = Windows.Forms.DialogResult.OK Then
dFelfogasSzama = MyForm.GetFelfogasSzama
dSzikrakozErtek = MyForm.GetSzikrakozErtek
Dim fileNew1 As FileNew
fileNew1 = Ses.Parts.FileNew()
fileNew1.TemplateFileName = "Blank"
fileNew1.Application = FileNewApplication.Gateway
fileNew1.Units = Part.Units.Millimeters
'fileNew1.TemplateType = FileNewTemplateType.Item
'Dim currprt as String = Ses.Parts.Work.FullPath
Dim addprt as String
If dSzikrakozErtek = 0 Then
addprt = "-" & dFelfogasSzama & "-00" & ".prt"
Else
addprt = "-" & dFelfogasSzama & "-" & dSzikrakozErtek*200 & ".prt"
End If
'------------
Dim f, f2 as string
f = E_file_name
f2 = Replace (f, "_", "")
f2 = Replace (f2, "-", "")
Dim Epos as integer = InStr(f2, "E")
If Len(Left$(f2, Epos )) = 7 Then
f2 = Replace (f2, "E", "00E") & addprt
Else
f2 = f2 & addprt
End If
Dim parentprt as String = Replace (currprt, E_file_name, f2)
fileNew1.NewFileName = parentprt
fileNew1.MasterFileName = ""
fileNew1.UseBlankTemplate = True
fileNew1.MakeDisplayedPart = True
Dim nXObject8 As NXObject
nXObject8 = fileNew1.Commit()
workPart = Ses.Parts.Work
fileNew1.Destroy()
'Dim result1 As Boolean = Ses.IsCamSessionInitialized()
'Dim kinematicConfigurator1 As SIM.KinematicConfigurator = workPart.CreateKinematicConfigurator()
Ses.ListingWindow.WriteLine(parentprt)
Dim part1 As Part = CType(Ses.Parts.FindObject( E_file_name ), Part)
Dim basePoint1 As Point3d
basePoint1.x=-MachiningZero(0)
basePoint1.y=-MachiningZero(1)
basePoint1.z=-MachiningZero(2)
Dim orientation1 As Matrix3x3
orientation1.Xx = 1.0
orientation1.Xy = 0.0
orientation1.Xz = 0.0
orientation1.Yx = 0.0
orientation1.Yy = 1.0
orientation1.Yz = 0.0
orientation1.Zx = 0.0
orientation1.Zy = 0.0
orientation1.Zz = 1.0
Dim partLoadStatus1 As PartLoadStatus
Dim component1 As Assemblies.Component
component1 = workPart.ComponentAssembly.AddMasterPartComponent(part1, "None", E_file_name, basePoint1, orientation1, -1, partLoadStatus1)
partLoadStatus1.Dispose()
'----------------------
'expression from the input value
'----------------------
Dim myExpName As String = "offset"
Dim myStringValue As String = "-" & (MyForm.GetSzikrakozString())
Dim MyExpression As Expression
Dim expExists As Boolean = False
For Each myExp As Expression In workPart.Expressions.ToArray
If myExp.Name = myExpName Then
expExists = True
MyExpression = myExp
Exit For
End If
Next
Dim unit1 As Unit = CType(workPart.UnitCollection.FindObject("MilliMeter"), Unit)
If Not expExists Then
MyExpression = workPart.Expressions.CreateWithUnits(myExpName & "=" & myStringValue, unit1)
Else
MyExpression.RightHandSide = myStringValue
End If
'----------------------
'Ses.ListingWindow.Open
'Ses.ListingWindow.WriteLine("")
'----------------------
End If
Catch ex As NXException
' displayedPart.LogFile.WriteLine(ex.ToString)
Finally
UFSes.Ui.UnlockUgAccess(UFConstants.UF_UI_FROM_CUSTOM)
UFSes.Abort.EnableAbort()
End Try
MyForm.Close
MyForm.Dispose
MyForm = Nothing
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Critical, "Error, Aborting!")
End Try
Application.Exit()
'=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
'reorient electrode part according to calculated Matrix
'=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Dim Alkatresz As Assemblies.Component
For Each MyComponent As Assemblies.Component In workPart.ComponentAssembly.RootComponent.GetChildren
'Ses.listingwindow.Writeline("MyComponent.name.ToLower()= " & MyComponent.name.ToLower() & "E_file_name.ToLower() :" & E_file_name.ToLower())
If MyComponent.name.ToLower() = E_file_name.ToLower() Then
Alkatresz = MyComponent
End If
Next
Dim NullEltolas As Vector3d = New Vector3d(0, 0, 0)
Dim ForgatasiMtx As Matrix3x3
ForgatasiMtx.Xx = mtx_vals(0)
ForgatasiMtx.Xy = mtx_vals(1)
ForgatasiMtx.Xz = mtx_vals(2)
ForgatasiMtx.Yx = mtx_vals(3)
ForgatasiMtx.Yy = mtx_vals(4)
ForgatasiMtx.Yz = mtx_vals(5)
ForgatasiMtx.Zx = mtx_vals(6)
ForgatasiMtx.Zy = mtx_vals(7)
ForgatasiMtx.Zz = mtx_vals(8)
'Ses.listingwindow.Writeline( "ForgatasiMtx" )
'Ses.listingwindow.Writeline(ForgatasiMtx.Xx & "; " & ForgatasiMtx.Xy & "; " & ForgatasiMtx.Xz)
'Ses.listingwindow.Writeline(ForgatasiMtx.Yx & "; " & ForgatasiMtx.Yy & "; " & ForgatasiMtx.Yz)
'Ses.listingwindow.Writeline(ForgatasiMtx.Zx & "; " & ForgatasiMtx.Zy & "; " & ForgatasiMtx.Zz)
Dim moving as integer = Movepart(NullEltolas, ForgatasiMtx, Alkatresz)
'=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
'IMPORT CAM
'=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Dim partImporter1 As PartImporter
partImporter1 = workPart.ImportManager.CreatePartImporter()
partImporter1.FileName = "y:\_NX\EF_custom\templates\Elektrodamaras_negoffset.prt"
'Ses.ListingWindow.WriteLine(partImporter1.FileName)
partImporter1.Scale = 1.0
partImporter1.CreateNamedGroup = False
partImporter1.ImportViews = False
partImporter1.ImportCamObjects = True
partImporter1.LayerOption = PartImporter.LayerOptionType.Original
partImporter1.DestinationCoordinateSystemSpecification = PartImporter.DestinationCoordinateSystemSpecificationType.Work
Dim nXMatrix1 As NXMatrix = CType(workPart.NXMatrices.FindObject("WCS"), NXMatrix)
partImporter1.DestinationCoordinateSystem = nXMatrix1
Dim destinationPoint1 As Point3d = New Point3d(0.0, 0.0, 0.0)
partImporter1.DestinationPoint = destinationPoint1
Dim nXObject7 As NXObject
nXObject7 = partImporter1.Commit()
partImporter1.Destroy()
'=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
'Move Minmaxpoints
'=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
'E_file_name
'solidbody: E_solidbody
'Dim bod as Body = E_solidbody In E_file_name
'Dim component11 As Assemblies.Component = E_file_name
'Dim bod as Body =CType(component11.E_solidbody, Body)
'Dim outp(3) as Double
'outp = Ask_XY_bounds (bod)
'For Each aPoint As Point In workPart.Points
' If apoint.name= "Min"
' aPoint.x = outp(1)
' aPoint.y = outp(3)
' aPoint.z = -magassag
' End If
' If apoint.name= "Max"
' apoint.x = outp(0)
' apoint.y = outp(2)
' apoint.z = 0
' End If
'Next
'=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
'=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
End Sub
'=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
'=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#
'=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Function get_longest_edge_vec(ByVal edges() As Edge) As Double()
Dim inx As Integer = 0
Dim Oldalelhossz as Double = 0
Dim vec(2) as Double
vec(0)=1
vec(1)=0
vec(2)=0
For inx = 0 To edges.GetUpperBound(0)
If edges(inx).SolidEdgeType.ToString = "Linear" Then
Dim Vizsgalt_elhossz as Double = edges(inx).GetLength()
If Vizsgalt_elhossz > Oldalelhossz Then
Oldalelhossz = Vizsgalt_elhossz
Dim sp(2) As Double
Dim ep(2) As Double
Dim lineData As UFCurve.Line
'lineData.start_point = sp
'lineData.end_point = ep
UFSes.Curve.AskLineData(edges(inx).Tag, lineData)
sp = lineData.start_point
ep = lineData.end_point
UFSes.Vec3.Sub(ep, sp, vec)
vec(0)= vec(0) / Oldalelhossz
vec(1)= vec(1) / Oldalelhossz
vec(2)= vec(2) / Oldalelhossz
End If
End If
Next inx
Return vec
End Function
Function get_edge_center(ByVal aEdge As Edge) As Double()
Dim arc_evaluator As System.IntPtr
Dim arc_data As NXOpen.UF.UFEval.Arc
Dim aEdge_tag As Tag = aEdge.Tag
Dim pointPos as integer 'pont ellenorzesehez, hogy kivul van-e a testen
UFSes.Eval.Initialize(aEdge_tag, arc_evaluator)
UFSes.Eval.AskArc(arc_evaluator, arc_data)
Return arc_data.center
End Function
Public Function Ask_XY_bounds(ByVal bod as Body) As Double()
Dim iCount, iIndex As Integer
Dim tPlane as tag
Dim dist(3), outp(3), dPoint(2), dDirection(2) As Double
Dim selpnt(1), pnt As Point3d
Dim accu As New Double
Dim MarkId As Session.UndoMarkId
tPlane = tag.Null
For iCount = 0 To 3
Select Case iCount
Case 0
dPoint(0) = 5000
dDirection(0) = 1
'XMAX
Case 1
dPoint(0) = -5000
dDirection(0) = -1
'XMIN
Case 2
dPoint(0) = 0
dPoint(1) = 5000
dDirection(0) = 0
dDirection(1) = 1
Case 3
dPoint(1) = -5000
dDirection(1) = 1
'YMAX
End Select
MarkID = ses.SetUndoMark(Session.MarkVisibility.Invisible, "Datum Plane")
ufses.Modl.CreateFixedDplane(dPoint, dDirection, tPlane)
dist(iCount) = ses.Measurement.GetMinimumDistance(bod, NXObjectManager.Get(tPlane), selpnt(0), selpnt(1), accu)
Ses.UpdateManager.AddToDeleteList( NXObjectManager.Get(tPlane) )
Ses.UpdateManager.DoUpdate(MarkID)
Ses.DeleteUndoMark(MarkID, "Datum Plane")
outp(0) = dist(1) - 5000
outp(1) = dist(3) - 5000
outp(2) = 5000 - dist(0)
outp(3) = 5000 - dist(2)
Next
Return outp
End Function
Public Function Movepart(ByVal eltolas As Vector3d, forgatasiMtx As Matrix3x3, mozgatandoAlkatresz As Assemblies.Component ) As Integer
Dim nullAssemblies_Component As Assemblies.Component = Nothing
Dim compoPositioner As Positioning.ComponentPositioner = workPart.ComponentAssembly.Positioner
Dim My_network As Positioning.Network
My_network = compoPositioner.EstablishNetwork()
Dim compoNetwork As Positioning.ComponentNetwork = CType(My_network, Positioning.ComponentNetwork)
compoNetwork.MoveObjectsState = True
compoNetwork.DisplayComponent = nullAssemblies_Component
compoNetwork.NetworkArrangementsMode = Positioning.ComponentNetwork.ArrangementsMode.Existing
compoNetwork.RemoveAllConstraints()
Dim mozgatandoObjects(0) As NXObject
mozgatandoObjects(0) = mozgatandoAlkatresz
compoNetwork.SetMovingGroup(mozgatandoObjects)
compoNetwork.BeginDrag()
compoNetwork.DragByTransform(eltolas, forgatasiMtx)
compoNetwork.EndDrag()
compoNetwork.ResetDisplay()
compoNetwork.ApplyToModel()
compoNetwork.Solve()
compoPositioner.ClearNetwork()
compoPositioner.DeleteNonPersistentConstraints()
compoPositioner.EndMoveComponent()
Return 1
End Function
End Module