hexagon logo

Just a couple little scripts

Hey everyone. Here are a few scripts I made working on a new part. I run all of these from the basic script editor. This first one I made to change the vectors of all auto vector points to (0,0,1). This could be altered to change to whatever vectors you need!


Dim DmisApp As Object
Dim DmisPart As Object
Dim DmisCommands As Object
Dim DmisCommand As Object

Sub Part1
Set DmisApp = CreateObject("PCDLRN.Application")
Set DmisPart = DmisApp.ActivePartProgram
Set DmisCommands = DmisPart.Commands
Set DmisCommand = DmisCommands.CurrentCommand
DmisCommands.InsertionPointAfter DmisCommand

For Each DmisCommand In DmisCommands

If DmisCommand.Type = CONTACT_VECTOR_POINT_FEATURE Then

' Set Theo I (X vector)
retval = DmisCommand.PutText ("0", THEO_I, 0)

' Set Theo J (Y vector)
retval = DmisCommand.PutText ("0", THEO_J, 0)

' Set Theo K (Z vector)
retval = DmisCommand.PutText ("1", THEO_K, 0)

' Set Meas I (X vector)
retval = DmisCommand.PutText ("0", MEAS_I, 0)

' Set Meas J (Y vector)
retval = DmisCommand.PutText ("0", MEAS_J, 0)

' Set Meas K (Z vector)
retval = DmisCommand.PutText ("1", MEAS_K, 0)

' Set Target I (X vector)
retval = DmisCommand.PutText ("0", TARG_I, 0)

' Set Target J (Y vector)
retval = DmisCommand.PutText ("0", TARG_J, 0)

' Set Target K (Z vector)
retval = DmisCommand.PutText ("1", TARG_K, 0)


End If

Next DmisCommand


End Sub

Sub Main

Part1

DmisPart.RefreshPart
End Sub
​




This one will change the measurement mode of all auto vector points (find noms, master, nominals, vector).


Dim DmisApp As Object
Dim DmisPart As Object
Dim DmisCommands As Object
Dim DmisCommand As Object

Sub Part1
Set DmisApp = CreateObject("PCDLRN.Application")
Set DmisPart = DmisApp.ActivePartProgram
Set DmisCommands = DmisPart.Commands
Set DmisCommand = DmisCommands.CurrentCommand
DmisCommands.InsertionPointAfter DmisCommand

For Each DmisCommand In DmisCommands

If DmisCommand.Type = CONTACT_VECTOR_POINT_FEATURE Then

' Set Measurement mode To Nominals
retval = DmisCommand.PutText ("NOMINALS", FIND_NOMS_TYPE, 0)


End If

Next DmisCommand


End Sub

Sub Main

Part1

DmisPart.RefreshPart
End Sub
​


This last one will write all of your XYZ data to a defined text file in a CSV format. Just create a txt file and insert the path file, then use the LEFT/RIGHT function to get the point ID. In this specific case I had a group of points that all ended with "PKT14". (Example: P1_PKT14, P2_PKT14_ P3_PKT14).


Dim DmisApp As Object
Dim DmisPart As Object
Dim DmisCommands As Object
Dim DmisCommand As Object
Dim TheoX, TheoY, TheoZ As String
Dim FilePath As String

Sub Part1
Set DmisApp = CreateObject("PCDLRN.Application")
Set DmisPart = DmisApp.ActivePartProgram
Set DmisCommands = DmisPart.Commands
Set DmisCommand = DmisCommands.CurrentCommand
DmisCommands.InsertionPointAfter DmisCommand

FilePath="INSERT THE PATH TO YOUR TXT FILE HERE"
Open FilePath For Append As #1

For Each DmisCommand In DmisCommands

If Right(DmisCommand.ID, 5) = "PKT14" Then

'Get Theo X (Theoretical X value)
TheoX=DmisCommand.GetText (THEO_X, 0)
'MsgBox(TheoX)


'Get Theo Y (Theoretical Y value)
TheoY=DmisCommand.GetText (THEO_Y, 0)
'MsgBox(TheoY)

'Get Theo Z (Theoretical Z value)
TheoZ=DmisCommand.GetText (THEO_Z, 0)
'MsgBox(TheoZ)


Print #1, TheoX &"," & TheoY & "," & TheoZ

End If

Next DmisCommand

Close #1


End Sub

Sub Main

Part1

DmisPart.RefreshPart
​


Happy Hump Day!!!