hexagon logo

Change name of XML report

Hello,
In both PCDMIS 2018 and PCDMIS 2021.2 we are saving XML reports to a network file server and would like to force the filename to be the serial number of the part.
Is this possible?
Thanks!
z
Parents Reply Children
  • You can append that easily to your file name if your file name is controlled within your program. I put the underscore there, but you can just remove it.

    ASSIGN/V1=GETPROGRAMINFO("PARTNAME") + "_" + GETPROGRAMINFO("SERIALNUMBER")

    Put variable in comment for example.

  •   

    Thanks, but how does xml stats export know to utilize this variable in the name of the xml file?

  • Apparently that doesn't work,

    but you can insert a basic script into your measurement routine that controls the entire XML export process, including the file name and file path.
    There's even an example in the help file,
    Would this option be ok for you?

    but this XML export is the entire measurement routine with all commands and comments... is that even the same thing that zoomable was talking about?


  •  

    Yep that would be great....can you direct me to the help file where this is shown?

    In the meantime, I'm going to dig around myself.

  • ExportToXML Method

    The example still lacks how to adjust the path. If you want to wait, I can complete the script for you later

  •  This looks like it exports the measurement routine as an XML and not the stats/reporting. If you want the whole routine, then this should be simple enough.

  •    

    I think this does export the entire routine along with the routines captured part data?  Correct?

    I'm not sure this is ideal for us...we just want the measurement data exported to an XML file, BUT with a properly formated naming convention. As of right now the exported name is a bunch of nonsense.

    Maybe Henninger can have a look at the below code, but this is what I came up with if we were going to try and export all the routines and measurement data, not ideal in our situation though:

    Sub Main
        Dim App As Object
        Set App = CreateObject("PCDLRN.Application")
        Dim Part As Object
        Set Part = App.ActivePartProgram
    
        ' Set Part Number from variable taken from PCDMIS
        Dim part_number As Object
        Set part_number = Part.GetVariableValue("PN")
    
        ' Set Serial Number from variable taken from PCDMIS
        Dim serial_number As Object
        Set serial_number = Part.GetVariableValue("SN")
    
        ' Get the current date and time and format it
        Dim currentDateTime
        currentDateTime = Format(Now, "yyyyMMdd_HHmmss")
    
        ' Add part_number, serial_number, date, time into the export path
        Dim exportPath As String
        exportPath = "d:\temp\" & part_number & "_" & serial_number & "_" & currentDateTime.xml"
    
        ' Exporting the measurement routine
        Part.ExportToXML exportPath
    
    
    End Sub
    

  • Do you need the Part Number and Serial Number to be variable statements? If not, you can do it this way.

    Sub Main
    
    Dim DmisApp As Object
    Dim DmisPart As Object  
    Dim PartSerial As String
    Dim PartName As String
    
    Set DmisApp = CreateObject("PCDLRN.Application")
    Set DmisPart = DmisApp.ActivePartProgram
    Set PartSerial = DmisPart.SerialNumber
    Set PartName = DmisPart.PartName
    
    Dim currentDateTime
        currentDateTime = Format(Now, "yyyyMMdd_HHmmss")
    
    Dim exportPath As String
        exportPath  = "D:\temp\" & PartName & "_" & PartSerial & "_" & currentDateTime & ".xml"
    
    DmisPart.ExportToXML ExportPath
        
    End Sub

    I think the exported name was messed up because of the end of the file name the ".xml" needs to be separated from the variable.

    My end result for file name is PartNumber_SerialNumber_20240221_120217

    There is also the option of putting XMLSTATS before each dimension and it will create an XML after running of those dimensions. Only problem is that it has extra data like the graphical analysis setting, etc. Example below of 1 Location feature.

        <!--Dimension Location-->
        <Command Type="Dimension Location" CTN="1000" UID="70996" id="LOC1">
          <DataField Description="Id" Value="LOC1" DTN="2" />
          <DataField Description="Reference Id" Value="CIR1" DTN="3" />
          <DataField Description="Graphic Analysis" Value="OFF" DTN="162" ToggleIndex="1" />
          <DataField Description="Textual Analysis" Value="OFF" DTN="163" ToggleIndex="1" />
          <DataField Description="Arrow Multiplier" Value="10" DTN="164" />
          <DataField Description="Arrow Density" Value="100" DTN="886" />
          <DataField Description="Output Type" Value="BOTH" DTN="165" ToggleIndex="3" />
          <DataField Description="Unit Type" Value="IN" DTN="172" ToggleIndex="1" />
          <DataField Description="Standard Deviation" Value="0" DTN="181" />
          <DataField Description="Half Angle" Value="NO" DTN="880" ToggleIndex="1" />
          <CurrentAlignment Alignment_UID="69952" />
        </Command>
        <!--D Location-->
        <Command Type="D Location" CTN="1005" UID="71093">
          <DataField Description="Axis" Value="D" DTN="132" />
          <DataField Description="Nominal" Value="1.0000" DTN="166" />
          <DataField Description="Measured" Value="1.0000" DTN="328" />
          <DataField Description="Plus Tolerance" Value="0.0050" DTN="167" />
          <DataField Description="Minus Tolerance" Value="0.0050" DTN="168" />
          <DataField Description="Max" Value="0.0000" DTN="332" />
          <DataField Description="Min" Value="0.0000" DTN="336" />
          <DataField Description="Deviation" Value="0.0000" DTN="340" />
          <DataField Description="Out Tol" Value="0" DTN="344" />
          <DataField Description="Output to Report" Value="YES" DTN="970" ToggleIndex="2" />
          <CurrentAlignment Alignment_UID="69952" />
        </Command>
        <!--End Dimension-->

  • good day,

    I had already indicated before that ExportToXML exports the entire routine.
    But you just need the measurement results, right?
    How exactly have you created the xml files so far?

  • Hello,

    I found another XML function. This only spits out the measurement results and should be what you were looking for.
    Please be careful with the format function, you have to specify minutes as nn otherwise it will confuse it with month (at least the basic compiler of pcdmis)

    Sub Main
     ' Error
       On Error Resume Next
    
     ' Dim something
       Dim DmisApp As Object
       Dim DmisPart As Object  
       Set DmisApp = CreateObject("PCDLRN.Application")
       Set DmisPart = DmisApp.ActivePartProgram
       Dim sPath, sPart_name, sOrder_number, sPart_number, sSerial_number As String
       Dim sCurrentDateTime As String
        
     ' generate Path
       sPart_name = Trim(DmisPart.PartName) 'Name of the measurement routine
       sOrder_number = Trim(DmisPart.SerialNumber) 'Order number Or delivery note number ?
       sPart_number = Trim(CStr(Part.GetVariableValue("PN"))) 'item number ?
       sSerial_number = Trim(CStr(Part.GetVariableValue("SN"))) 'serial number
       sCurrentDateTime = Format(Now, "yyyyMMdd_hhnnss")
    
       sPath = "D:\temp\"
       sPath = sPath & sPart_name
       If sPart_number <> "" Then sPath = sPath & "_" & sPart_number 
       If sOrder_number <> "" Then sPath = sPath & "_" & sOrder_number
       If sSerial_number <> "" Then sPath = sPath & "_" & sSerial_number
       sPath = sPath & "_" & sCurrentDateTime & ".xml"
    
    
     ' Export
       'DmisPart.ExportToXML sPath
       DmisPart.ExportStatsFile sPath, True
       
     ' unDim something
       Set DmisPart = Nothing
       Set DmisApp = Nothing
    End Sub