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
  • We were using csv exports where we could change the filename to whatever we wanted now they are asking for xml outputs.

    I don't see a way to modify the name inside pcdmis without doing some vba scripting?  Anyone have any idea how this could be done or if it simply cannot be done?

Reply
  • We were using csv exports where we could change the filename to whatever we wanted now they are asking for xml outputs.

    I don't see a way to modify the name inside pcdmis without doing some vba scripting?  Anyone have any idea how this could be done or if it simply cannot be done?

Children
  • What exactly are you wanting to do? You may be able do this without VBA scripting. If not, are you willing to use a Basic Script?

  • I just want the part number and serial number on it.

  • 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-->