Skip to main content
12-Amethyst
February 20, 2025
Solved

VB API export a table to csv format - Data type?

  • February 20, 2025
  • 1 reply
  • 834 views

Hi, I’m new to my company, and we use Creo 9.0. Previously, I worked with SolidWorks and developed some useful VB tools there. Now, I’d like to replicate that for Creo.

One task I’m trying to accomplish is verifying whether all parts have the correct parameters. I’ve created a VB.NET code to:

  1. Generate a drawing template and use the repeat region to collect all the parameters in parts within an assembly.
  2. Export the table to a CSV file so I can analyze it in Excel.

However, I’m encountering an issue when exporting the table to CSV. The problem is that not all models have the same parameters. When I use the repeat region to generate the table, some cells are empty. Whenever my VB program encounters these empty cells, it stops running.

I believe the issue is related to data types. The VB API seems to handle only text formats (stringseq), but when it encounters an empty cell or a cell containing a real number, the program throws an error.

Does anyone have a solution for handling different data types in this situation?

 

Thanks for your kindly help. 

 

Best answer by SC_TK

Ok, I found the solution. When there was no such parameter in the components. The data type in the blank cell is not stringseq as some forum suggested. But I can use relation to convert them into text 

Here is an example of what I did. 

if exists ("asm_mbr_size")
	SIZE_TEXT =asm_mbr_size
else
	SIZE_TEXT ="-"
endif


then I replace "&asm_mbr_size" in the repeat region by "&rpt.rel.SIZE_TEXT".  That will force the blank cell to be "-". which is a string and can be extracted by GetText 

1 reply

SC_TK12-AmethystAuthorAnswer
12-Amethyst
February 23, 2025

Ok, I found the solution. When there was no such parameter in the components. The data type in the blank cell is not stringseq as some forum suggested. But I can use relation to convert them into text 

Here is an example of what I did. 

if exists ("asm_mbr_size")
	SIZE_TEXT =asm_mbr_size
else
	SIZE_TEXT ="-"
endif


then I replace "&asm_mbr_size" in the repeat region by "&rpt.rel.SIZE_TEXT".  That will force the blank cell to be "-". which is a string and can be extracted by GetText