Your Products have been synced, click here to refresh
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?
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.
The example still lacks how to adjust the path. If you want to wait, I can complete the script for you later
lovethepirk 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
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
Hey Henniger, is there a way to have a script, or this script delete data from a range of specific lines to trim more fat off the XML export? This export method is way better but it includes every comment in the program, even the document type ones. This is awesome though, I was looking at this method yesterday. Good work.
I don't know what causes it, but the GetVariableValue generates empty strings when they are set As String.
The file name generated using your script is PartName_OrderNumber_Date_Time - Looks like it isn't using the Variable Values for some reason
But with mine it generates PartName_PartName_OrderNumber_SerialNumber_Date_Time
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 As String Dim sPart_number, sSerial_number As Object Dim sCurrentDateTime As String ' generate Path Set sPart_name = Trim(DmisPart.PartName) 'Name of the measurement routine Set sOrder_number = Trim(DmisPart.SerialNumber) 'Order number Or delivery note number ? Set sPart_number = DmisPart.GetVariableValue("PN") 'item number ? Set sSerial_number = DmisPart.GetVariableValue("SN") 'serial number Set sCurrentDateTime = Format(Now, "yyyyMMdd_hhnnss") sPath = "C:\CMM\" sPath = sPath & sPart_name If sPart_number.StringValue <> "" Then sPath = sPath & "_" & sPart_number.StringValue MsgBox(sPath) If sOrder_number <> "" Then sPath = sPath & "_" & sOrder_number If sSerial_number.StringValue <> "" Then sPath = sPath & "_" & sSerial_number.StringValue MsgBox(sPath) sPath = sPath & "_" & sCurrentDateTime & ".xml" ' Export 'DmisPart.ExportToXML sPath DmisPart.ExportStatsFile sPath, True ' unDim something Set DmisPart = Nothing Set DmisApp = Nothing End Sub
yes the return value for GetVariableValue is an object, of course you are right. I didn't test this and therefore overlooked this error.
The generated XML file can be opened and modified like a text file, which in itself is not a problem. You just have to parse it correctly so that you can find the comments within the file
Hello,
I did it that way, it crashed for me because the folder in the path doesn't exist, hence the additional if test.
Sub Main_240223() ' 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, sPath2, sPart_name, sOrder_number, sLine As String Dim oPart_number, oSerial_number As Object Dim sCurrentDateTime As String Dim OFSO As Object ' get Head data sPart_name = Trim(DmisPart.PartName) 'Name of the measurement routine sOrder_number = Trim(DmisPart.SerialNumber) 'Order number Or delivery note number ? Set oPart_number = DmisPart.GetVariableValue("PN") 'item number ? Set oSerial_number = DmisPart.GetVariableValue("SN") 'serial number sCurrentDateTime = Format(Now, "yyyyMMdd_hhnnss") ' generate Path Set OFSO = CreateObject("Scripting.FileSystemObject") sPath = "D:\Temp\" If Not OFSO.FolderExists(sPath) Then Exit Sub sPath = sPath & sPart_name If oPart_number.StringValue <> "" Then sPath = sPath & "_" & oPart_number.StringValue If sOrder_number <> "" Then sPath = sPath & "_" & sOrder_number If oSerial_number.StringValue <> "" Then sPath = sPath & "_" & oSerial_number.StringValue sPath2 = sPath & "_" & sCurrentDateTime & "_MOD" & ".xml" sPath = sPath & "_" & sCurrentDateTime & ".xml" ' export 'DmisPart.ExportToXML sPath DmisPart.ExportStatsFile sPath, True ' trim comments If Len(Dir(sPath)) > 0 Then Open sPath For Input As #1 Open sPath2 For Output As #2 Do Until EOF(1) Line Input #1, sLine If InStr(1, sLine, "CommentCmd") = 0 Then Print #2, Left(sLine, Len(sLine) - 1) End If Loop Close #1 Close #2 End If ' unDim something Set DmisPart = Nothing Set DmisApp = Nothing End Sub
You could now shorten each line of unwanted information using the Replace function (or similar).
© 2024 Hexagon AB and/or its subsidiaries. | Privacy Policy | Cloud Services Agreement |