Your Products have been synced, click here to refresh
[FONT=UICTFontTextStyleBody]ASSIGN/COUNT=0 [/FONT][FONT=UICTFontTextStyleBody]DO/[/FONT] [FONT=UICTFontTextStyleBody]ASSIGN/V1 = GETCOMMAND("CONSTRUCTED SET","UP",1)[/FONT] [FONT=UICTFontTextStyleBody]ASSIGN/COUNT = COUNT + 1 [/FONT][FONT=UICTFontTextStyleBody]ASSIGN/V2 = GETTEXT(3,COUNT,V1)[/FONT] [FONT=UICTFontTextStyleBody]ASSIGN\T_VAL_1=DOT((V2.XYZ-V2.TXYZ),V2.TIJK)[/FONT] [FONT=UICTFontTextStyleBody]ASSIGN/T_VAL = FORMAT("%.4f",T_VAL)[/FONT] [FONT=UICTFontTextStyleBody]COMMENT/REPT,"TVAL "+V2+" = "+T_VAL[/FONT] [FONT=UICTFontTextStyleBody]UNTIL/COUNT>SCN1.NUMHITS-1
Dim oPcd As PCDLRN.Application = New PCDLRN.Application Dim oCmds As Object = oPcd.ActivePartProgram.Commands Dim oPnt As Command Dim mX As Double Dim mY As Double Dim mZ As Double Dim tX As Double Dim tY As Double Dim tZ As Double Dim sVals As String = "" oPcd.Visible = False For Each oCmd As Command In oCmds If oCmd.IsDimension AndAlso oCmd.Type = DIMENSION_PROFILE Then sVals &= oCmd.ID & vbCrLf Dim fs As Command = oCmds.item(oCmd.DimensionCommand.Feat1) 'get the referenced feature set For i As Integer = 1 To fs.FeatureCommand.NumHits 'iterate through each point in the feature set oPnt = oCmds.item(fs.GetText(REF_ID, i)) 'get the point command oPnt.FeatureCommand.GetPoint(FPOINT_TYPES.FPOINT_CENTROID, FDATA_DATASET.FDATA_MEAS, mX, mY, mZ) 'get measured values oPnt.FeatureCommand.GetPoint(FPOINT_TYPES.FPOINT_CENTROID, FDATA_DATASET.FDATA_TARG, tX, tY, tZ) 'get theo values Dim dDeviation As Double = Math.Sqrt((tX - mX) ^ 2 + (tY - mY) ^ 2 + (tZ - mZ) ^ 2) 'calculate deviation sVals &= " " & oPnt.ID & " " & dDeviation.ToString("###0.0000") & vbCrLf Next End If Next oPcd.Visible = True oCmds = Nothing oPcd = Nothing Console.WriteLine(sVals)
You can get T values directly from a scan but if you need to pull from the point set referenced by a dimension then Bjacobson has you covered.
bjacobson is quite the code monkey! You're in good company here, then!
Welcome!
Sub Main() Dim PCDApp, PCDPartPrograms, PCDPartProgram, PCDCommands, PCDCommand Dim PCDFeatCmd Dim Prbhit Dim numhits, nhits As Integer Set PCDApp = CreateObject("PCDLRN.Application") Set PCDPartPrograms = PCDApp.PartPrograms Set PCDPartProgram = PCDActivePartProgram Set PCDCommands = PCDPartProgram.Commands Dim cmd As Object Dim Fcntr As Integer Dim FeatureList$(99999) Dim MX, MY, MZ, TX, TY, TZ, Xdev, Ydev, Zdev, MI, MJ, MK, TI, TJ, TK As Double Fcntr = 0 For Each cmd In PCDCommands If cmd.Type = 596 Then 'Feaure Set FeatureList(Fcntr) = cmd.id Set PCDCommand = PCDCommands.Item(FeatureList(Fcntr)) Set PCDFeatCmd =PCDCommand.FeatureCommand Fcntr = Fcntr + 1 Nhits = PCDFeatCmd.NumHits While fcntr<nhits+1 Set prbhit = PCDFeatCmd.GetHit(Fcntr, FHITDATA_CENTROID, FDATA_THEO, FDATA_PART, AlignID, PLANE_TOP) TX = CDbl(prbhit.x) TY = CDbl(prbhit.y) TZ = CDbl(prbhit.z) Set prbhit = PCDFeatCmd.GetHit(Fcntr, FHITDATA_VECTOR, FDATA_THEO, FDATA_PART, AlignID, PLANE_TOP) TI = CDbl(prbhit.i) TJ = CDbl(prbhit.j) TK = CDbl(prbhit.k) Set prbhit = PCDFeatCmd.GetHit(Fcntr, FHITDATA_CENTROID, FDATA_TMEAS,FDATA_PART, AlignID, PLANE_TOP) MX = CDbl(prbhit.x) MY = CDbl(prbhit.y) MZ = CDbl(prbhit.z) XDev = MX - TX YDev = MY - TY ZDev = MZ - TZ TVal = ((Xdev)*TI) + ((YDev)*TJ) + ((ZDev)*TZ) ' output the TVal to a file Fcntr = Fcntr + 1 Wend End If Next cmd Set PCDApp = nothing Set PCDPartPrograms = nothing Set PCDPartProgram = nothing Set prbhit = nothing End Sub
© 2024 Hexagon AB and/or its subsidiaries. | Privacy Policy | Cloud Services Agreement |