hexagon logo

How to get data from dimension of profile?

Hi, I first take five points and construct them to be a feature set. And then i caculate the profile.
how can i get the "T" for every point by the profile dimension with VB or VAB or C#? I use PCDMIS
2013. Thank you very much
  • Can't you dimension each point's "T" value individually?
  • In the edit window of PCDMIS

    TVAL's of points in a constructed feature set.


    The following code will:


    1) locate the feature set above the placement of the code
    2) pull out the individual feature by it's name
    3) calculate it's Tval
    4) FORMAT it to 4 decimal places
    5) and send it to the report screen

    The code must be placed below the feature set
    [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
    
    [/FONT]
  • Tried to edit above post, but can't do it on this wifi network.

    sorry.
  • You have to get the feature set from the profile, then get the points from the feature set, then calculate the deviation from the theo and meas XYZ values of the points:
            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 extract the T value for each point directly using the "get text" method. No need to recalculate it.

    Whoops, sorry, didn't read closely enough. 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!
  • 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.


    That would sure be nice...even .Deviation doesn't return a value on a point.

    bjacobson is quite the code monkey! You're in good company here, then!

    Welcome!


    Thanks! I've been lurking here for some time...thought it high time I start giving back what you've all taught me. Slight smile
  • bjacobson, thank you so much for your reply, and there is one problem, accroding to your code, I think all the T value are plus,
    but there sometimes T might be minus, right?
  • This will calculate +/- TVal's

    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
    


    Feel free to adapt to your specific needs.
  • Nice post DPH51 !
    I just wonder why using vb to calculate something which is easy to calculate with an assignment...