hexagon logo

Refresh the orientation of the probe in the graphical window (script)

Hello everyone,

First of all, I apologize for my poor use of English. I will try to make myself understood.

My problem is the following;

I'm working on a script to select the different orientations of my probe, but graphically I only manage to update it if I use the 'EXECUTE' command, but this option is a bit slow.


Sub selectProbe()  '************************************************************************************************************************************************************


Dim PCDApp, PCDPartPrograms, PCDPartProgram, PCDCommands, PCDCommand, PCDExecutionWindow, PCDLoadMachine, PCDMasterSlaveDlg, DRO, DROeX, ExecDlg, EditWindow, Optimizer, MyModel, DmisReport, PCDCadWindow, Machine
Dim cmd As Object
Dim probe As Variant

Dim posicionA As Integer
Dim posicionB As Integer
Dim Angle_A As Double
Dim Angle_B As Double
Dim Angle_A_Max As Double
Dim Angle_B_Max As Double
Dim Angle_A_Min As Double
Dim Angle_B_Min As Double
Dim valorAngle As Double
Dim activeTip As String
Dim BrazoActivo As String
Dim BrazoCheck As String
Dim LoadMachine As String
Dim numeroMaquinas As Integer
Dim Unico As String
dim ProbePosition as double

Set PCDApp = CreateObject("PCDLRN.Application")
Set PCDPartPrograms = PCDApp.PartPrograms
Set PCDPartProgram = PCDApp.ActivePartProgram
Set PCDCommands = PCDPartProgram.Commands
set PCDExecutionWindow = PCDApp.ActivePartProgram

Set EditWindow = PCDPartProgram.EditWindow
Set Optimizer = PCDPartProgram.OptimizePath
Set MyModel = PCDPartProgram.CadModel
Set PCDReport = PCDPartProgram.ReportWindow

Set Machine = PCDPartProgram.ActiveMachine

CommandCount = PCDCommands.Count


numeroMaquinas=0
valorAngle=7.5
Angle_A_Max=105
Angle_B_Max=180
Angle_A_Min=0
Angle_B_Min=-180


  For Each cmd In PCDCommands

    If cmd.Type = 171 Then
	
	numeroMaquinas=numeroMaquinas+1
	     
    End If
	
    If numeroMaquinas=2 Then valorAngle=5: Angle_A_Max=180: Angle_B_Max=180: Angle_A_Min=-180: Angle_B_Min=-180: Exit For

Next cmd

Set cmd = PCDCommands.CurrentCommand


if cmd.MasterArm = True then 
Set DRO = PCDPartProgram.GetReadoutWindow(1)
Angle_A = DRO.GetAAngle(1)
Angle_B = DRO.GetBAngle(1)
Set cmd = PCDCommands.Add(SET_ACTIVE_TIP, True)
cmd.SetMasterArm

elseif cmd.SlaveArm = True then
Set DRO = PCDPartProgram.GetReadoutWindow(2)
Angle_A = DRO.GetAAngle(2)
Angle_B = DRO.GetBAngle(2)
Set cmd = PCDCommands.Add(SET_ACTIVE_TIP, True)
cmd.SetSlaveArm

else
Angle_A = DRO.GetAAngle(PCDPartProgram.CurrentArm)
Angle_B = DRO.GetBAngle(PCDPartProgram.CurrentArm)
Set cmd = PCDCommands.Add(SET_ACTIVE_TIP, True)
end if


activeTip = "T1A" & Angle_A & "B" & Angle_B
retval = cmd.PutText(activeTip ,REF_ID, 0)

'PCDPartProgram.RefreshPart

		 Begin Dialog DIALOG_1 16,16, 125, 103, "Dialog One"
  TextBox 32,28,40,12, .Angle_A
  PushButton 76,28,8,8, "A+", .PushButton_1
  PushButton 76,36,8,8, "A-", .PushButton_2
  TextBox 32,48,40,12, .Angle_B
  PushButton 76,48,8,8, "B+", .PushButton_3
  PushButton 76,56,8,8, "B-", .PushButton_4
  OKButton 68,84,40,12
         End Dialog

again:

'cmd.ReDraw
'PCDPartProgram.RefreshPart

Dim Dlg1 As DIALOG_1

Dlg1.Angle_A=Angle_A
Dlg1.Angle_B=Angle_B


button = Dialog(Dlg1)


If Button = 1 and  Angle_A<Angle_A_Max Then Angle_A=Angle_A+valorAngle
If Button = 2 and  Angle_A>Angle_A_Min Then Angle_A=Angle_A-valorAngle

If Button = 3 and  Angle_B<Angle_B_Max Then Angle_B=Angle_B+valorAngle
If Button = 4 and  Angle_B>Angle_B_Min Then Angle_B=Angle_B-valorAngle


activeTip = "T1A" & Angle_A & "B" & Angle_B
retval = cmd.PutText(activeTip, REF_ID, 0)

cmd.EXECUTE


'DRO.CenterProbeOnGraphicsWindow=false

DRO.ShowCurrentProbePositionOnScreen=false
'msgbox DRO.ShowProbePosition

'cmd.ActiveComponent
PCDPartProgram.RefreshPart

If Button = 1 or Button = 2 or Button = 3 or Button = 4 Then GoTo Again


'***** Cleanup
Set PCDApp = Nothing
Set PCDPartPrograms = Nothing
Set PCDPartProgram = Nothing
Set PCDCommands = Nothing
Set EditWindow = Nothing
Set PCDReport = Nothing

'*****
        
        
End Sub


Sub Main()

selectProbe


End Sub

I have already tried using "RefreshPart" and the probe graphically does not move. Does anyone know how to do it? Thanks in advance.