Your Products have been synced, click here to refresh
You can use the code below to extract data from a command using the alignment you desire. It's .net, so you'll need to modify it for basic.
Sub MAIN() ' Post: http://www.pcdmisforum.com/forum/pc-dmis-enterprise-metrology-software/pc-dmis-code-samples/411735-vb-script-using-puttext-To-enter-an-expression Dim PCDApp As Object Dim PCDPartPrograms As Object Dim PCDPartProgram As Object Dim PCDCommands As Object Dim cmd As Object Dim editWin As Object Dim oTHEO As Object Set PCDApp = CreateObject("PCDLRN.Application") Set PCDPartPrograms = PCDApp.PartPrograms Set PCDPartProgram = PCDApp.ActivePartProgram Set PCDCommands = PCDPartProgram.Commands Set editWin = PCDPartProgram.EditWindow Dim fcntr As Integer Dim FeatureList$(99999) Dim TX, TY, TZ, NewTX, NewTY, NewTZ, txtBlock, alignID, txtBlockTmp, MSG As String Dim lastChr, findTHEO, findChr, firstComma, secondComma As Integer fcntr = 0 For Each cmd In PCDCommands If cmd.IsAlignment And cmd.ID <> "" Then alignID = cmd.ID End If If cmd.IsDCCFeature Or cmd.IsMeasuredFeature Then If cmd.Marked Then FeatureList(fcntr) = cmd.ID TX = CStr(cmd.FeatureCommand.GetHit(1, FHITDATA_CENTROID, FDATA_TARG, FDATA_PART, alignID, PLANE_TOP).X) TY = CStr(cmd.FeatureCommand.GetHit(1, FHITDATA_CENTROID, FDATA_TARG, FDATA_PART, alignID, PLANE_TOP).Y) TZ = CStr(cmd.FeatureCommand.GetHit(1, FHITDATA_CENTROID, FDATA_TARG, FDATA_PART, alignID, PLANE_TOP).Z) NewTX = TX & "+0" NewTY = TY & "+0" NewTZ = TZ & "+0" MSG = MSG & Chr(10) & Chr(10) & cmd.ID MSG = MSG & Chr(10) & Chr(10) & alignID MSG = MSG & Chr(10) & Chr(10) & "XTheo = " & TX MSG = MSG & Chr(10) & Chr(10) & "YTheo = " & TY MSG = MSG & Chr(10) & Chr(10) & "ZTheo = " & TZ MSG = MSG & Chr(10) & Chr(10) & "NewXTheo = " & NewTX MSG = MSG & Chr(10) & Chr(10) & "NewYTheo = " & NewTY MSG = MSG & Chr(10) & Chr(10) & "NewZTheo = " & NewTZ MsgBox MSG MSG = "" End If End If Next cmd Set PCDApp = Nothing Set PCDPartPrograms = Nothing Set PCDPartProgram = Nothing End Sub
As a general comment I'd add: Don't use gettext unless there really is no other way to extract the values you need! Almost everything (except FCF:s and SIZE:s) have a lot of predefined methods for getting the values. In the latest versions of PC-DMIS a description of the type library is included in the Help.
Also, gettext gives you language dependent results, going through the access functions mostly use language independent numeric constants instead.
I can extract the THEO values, but they don’t seem to be in the correct coordinate (alignment) system. What advice can you give an old programmer. (Using the basic supplied with PCDMIS).
Thanks
What about GomoFazters method(s) in the ToPoints thread? http://www.pcdmisforum.com/forum/pc-...691#post392691
Private Sub PullTheos() Dim PCDApp As PCDLRN.Application Dim PCDPart As PCDLRN.PartProgram Dim PCDCommands As Object Dim cmd As PCDLRN.Command Dim editWin As PCDLRN.EditWindow PCDApp = CreateObject("PCDLRN.Application") PCDPart = PCDApp.ActivePartProgram PCDCommands = PCDPart.Commands editWin = PCDPart.EditWindow Dim algnID As String = "" For Each cmd In PCDCommands If cmd.IsAlignment And cmd.ID <> "" Then algnID = cmd.ID End If If cmd.IsDCCFeature Or cmd.IsMeasuredFeature Then If cmd.Marked Then Dim oTHEO As PCDLRN.PointData = cmd.FeatureCommand.GetHit(1, PCDLRN.FHITDATA_TYPES.FHITDATA_CENTROID, PCDLRN.FDATA_DATASET.FDATA_THEO, PCDLRN.FDATA_COORDSYS.FDATA_PART, algnID, PCDLRN.ENUM_PLANE_TYPE.PLANE_TOP) MsgBox("Feature Name: " & cmd.ID & vbCr & "Alignment Name: " & algnID & vbCr & oTHEO.X.ToString & " " & oTHEO.Y.ToString & " " & oTHEO.Z.ToString) End If End If Next cmd PCDApp = Nothing PCDPart = Nothing PCDCommands = Nothing End Sub
Private Sub Values2Expression() Dim PCDApp As PCDLRN.Application Dim PCDPart As PCDLRN.PartProgram Dim PCDCommands As Object Dim cmd As PCDLRN.Command Dim editWin As PCDLRN.EditWindow Dim pNumTHEO As Integer = 4 Dim pNumVECT As Integer = 4 Dim pNumTARG As Integer = 4 PCDApp = CreateObject("PCDLRN.Application") PCDPart = PCDApp.ActivePartProgram PCDCommands = PCDPart.Commands editWin = PCDPart.EditWindow Dim algnID As String = "" For Each cmd In PCDCommands If cmd.IsAlignment And cmd.ID <> "" Then algnID = cmd.ID End If If cmd.IsDCCFeature Or cmd.IsMeasuredFeature Then If cmd.Marked Then Dim oTHEO As PCDLRN.PointData = cmd.FeatureCommand.GetHit(1, PCDLRN.FHITDATA_TYPES.FHITDATA_CENTROID, PCDLRN.FDATA_DATASET.FDATA_THEO, PCDLRN.FDATA_COORDSYS.FDATA_PART, algnID, PCDLRN.ENUM_PLANE_TYPE.PLANE_TOP) Dim oVECT As PCDLRN.PointData = cmd.FeatureCommand.GetHit(1, PCDLRN.FHITDATA_TYPES.FHITDATA_VECTOR, PCDLRN.FDATA_DATASET.FDATA_THEO, PCDLRN.FDATA_COORDSYS.FDATA_PART, algnID, PCDLRN.ENUM_PLANE_TYPE.PLANE_TOP) Dim oTARG As PCDLRN.PointData = cmd.FeatureCommand.GetHit(1, PCDLRN.FHITDATA_TYPES.FHITDATA_CENTROID, PCDLRN.FDATA_DATASET.FDATA_TARG, PCDLRN.FDATA_COORDSYS.FDATA_PART, algnID, PCDLRN.ENUM_PLANE_TYPE.PLANE_TOP) 'Dim iMessage As String = "Feature Name: " & cmd.ID & vbCr & "Alignment Name: " & algnID _ ' & vbCr & oTHEO.X.ToString("n" & pNumTHEO) & ", " & oTHEO.Y.ToString("n" & pNumTHEO) & ", " & oTHEO.Z.ToString("n" & pNumTHEO) _ ' & vbCr & oVECT.I.ToString("n" & pNumVECT) & ", " & oVECT.J.ToString("n" & pNumVECT) & ", " & oVECT.K.ToString("n" & pNumVECT) _ ' & vbCr & oTARG.X.ToString("n" & pNumTARG) & ", " & oTARG.Y.ToString("n" & pNumTARG) & ", " & oTARG.Z.ToString("n" & pNumTARG) 'MsgBox(iMessage) '__________________________________________________________________________________ 'Theoreticals to expression cmd.SetExpression(oTHEO.X.ToString("n" & pNumTHEO) & "+0", PCDLRN.ENUM_FIELD_TYPES.THEO_X, 0) cmd.SetExpression(oTHEO.Y.ToString("n" & pNumTHEO) & "+0", PCDLRN.ENUM_FIELD_TYPES.THEO_Y, 0) cmd.SetExpression(oTHEO.Z.ToString("n" & pNumTHEO) & "+0", PCDLRN.ENUM_FIELD_TYPES.THEO_Z, 0) '__________________________________________________________________________________ '__________________________________________________________________________________ 'Theoretical Vectors to expression cmd.SetExpression(oVECT.I.ToString("n" & pNumVECT) & "+0", PCDLRN.ENUM_FIELD_TYPES.THEO_I, 0) cmd.SetExpression(oVECT.J.ToString("n" & pNumVECT) & "+0", PCDLRN.ENUM_FIELD_TYPES.THEO_J, 0) cmd.SetExpression(oVECT.K.ToString("n" & pNumVECT) & "+0", PCDLRN.ENUM_FIELD_TYPES.THEO_K, 0) '__________________________________________________________________________________ '__________________________________________________________________________________ 'Targets to expression cmd.SetExpression(oTHEO.X.ToString("n" & pNumTARG) & "+0", PCDLRN.ENUM_FIELD_TYPES.TARG_X, 0) cmd.SetExpression(oTHEO.Y.ToString("n" & pNumTARG) & "+0", PCDLRN.ENUM_FIELD_TYPES.TARG_Y, 0) cmd.SetExpression(oTHEO.Z.ToString("n" & pNumTARG) & "+0", PCDLRN.ENUM_FIELD_TYPES.TARG_Z, 0) '__________________________________________________________________________________ '__________________________________________________________________________________ 'Target Vectors to expression cmd.SetExpression(oVECT.I.ToString("n" & pNumVECT) & "+0", PCDLRN.ENUM_FIELD_TYPES.TARG_I, 0) cmd.SetExpression(oVECT.J.ToString("n" & pNumVECT) & "+0", PCDLRN.ENUM_FIELD_TYPES.TARG_J, 0) cmd.SetExpression(oVECT.K.ToString("n" & pNumVECT) & "+0", PCDLRN.ENUM_FIELD_TYPES.TARG_K, 0) '__________________________________________________________________________________ End If End If Next cmd
© 2024 Hexagon AB and/or its subsidiaries. | Privacy Policy | Cloud Services Agreement |