hexagon logo

Excel to PC-DMIS and back again

So my company uses Excel to store our info and I am writing 2 VB scripts. The first script is executed at the start of the part program after the alignment and, after some user inputs, selects the correct excel file and imports the nominals and tolerances from the spreadsheet to the dimensions. At the end of the program a second script runs which exports the measured values of each dimension back to the spreadsheet. The problem however is that not all of the features are measured each time the part program is executed. I want the user to be able to skip measurements that are not needed. My script doesn't differentiate between skipped dimensions and measured so it might export an inaccurate value to the excel sheet. I am trying to solve this problem by having the first script also set the measured values of each feature based on the excel sheet. That way the value on the excel sheet will remain unchanged when the second script writes to it. The other possible solution is to only export values that were measured in the part program but I don't know any way to have the script determine that. Is there a function the returns whether a feature was measured or skipped during the current execution? Anyway my biggest problem is that I don't know the syntax to change the measured Z position of a feature to a value from excel. This is the code I have but it returns an error saying that it does not recognize "ZActual." Is there a good reference for syntax somewhere?

If Cmd.IsFeature then
Set DcmdID = Cmd.FeatureCommand
DimID = DCmdID.ID

If DimID = "HEAT PACK TOP" then
DCmd.ZActual = xlsheet.Range("J39").Value
End If
'repeat for a bunch of other features
End If

Any suggestions or solutions would be appreciated. Thanks.
  • Try

    If Cmd.IsFeature then
    Set Dcmd = Cmd.FeatureCommand
    DimID = DCmd.ID
    
    If DimID = "HEAT PACK TOP" then
    DCmd.Z = xlsheet.Range("J39").Value
    End If
    'repeat for a bunch of other features
    End If


    You can get good information from the PCDBASIC helpfile, and the expressionbuilder (for assignments) in PC-DMIS can help you show what properties you can read/write for commands/dimensions/features.
  • I am also trying to use PC-DMIS to Excel. I do not program thru VB so the code is all foreign to me. I have seen in other threads that there is a spreadsheet available to use but can't seem to get a response when asking for it to be emailed. I have been able to get the data to go to Excel but it puts it all into seperate sheets and not into the same page. Any and all help with this would be greatly appreciated as I am having to enter all the data in by hand.

    Thanks!
  • Hmm. No dice. I thought that might be it based on what was in the expression builder but it still says "Unknown Name - Z" It seems like the labels for a script are different than the ones in the expression builder. The workaround here is to somehow identify which features have been skipped during execution. Does anyone know how to do that?
  • PC-DMIS to Excel.zip

    This is a basic script to just pull all the dimensions out of the part program and put them into a new excel file. You don't need too much VB experience to tweak how they are formatted into the excel sheet so I would play around with it a bit if I were you tm_stark. Just be sure to save a copy of the original first. Wink
  • I had the Spreadsheet emailed to me yesterday! Haven't had a chance to see what it will do yet.
    I was able to get data to go to Excel before, just not into one sheet. Here's to hoping it works!
    Thanks again to Tim for emailing it to me! Slight smile
  • Hmm is there a way for the part program to execute the "Reset Measured Values to Nominal - All" command? Then I could just have it update the theoreticals for each feature and then run that command to change them to also be the measured values.
  • I have the spreadsheet and have been able to accomplish getting the data to actually go to the sheet! But my question is.... How do I write it into the program to go to THIS spreadsheet everytime the program runs? We have our production operators run their parts on the CMM and need the data everytime the part runs to go into the same spreadsheet. I have tried the Export to Excel and that doesn't cut it. Could someone please send me an example of how to accomplish this task?????
  • I find the export to excel option not to work very well. If you just need the raw data, the export to "generic" works well. It sends the data to a text file that can then be opened in excel as a comma separated file. It give the X, Y, Z, I, J, & K values for each feature followed by the same for each hit in that feature. If there is anything like diameter or length associated with the feature then it gives those as well.

    As to getting the data to go to a single sheet every time, just change the basic script that is exporting the data. Look for a line that identifies the excel file. It should contain something like "C:\Excel Stuff\Cool files\Parts and stuff.xls" If it is creating a new one, change it so that it opens an existing one. Then change the name of the file it references to the name of the file that you want it to open. Not having seen the code you are working with this is the best general answer I can give.