Community Tip - You can change your system assigned username to something more personal in your community settings. X

Translate the entire conversation x

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

SC_TK
12-Amethyst

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

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. 

 

ACCEPTED SOLUTION

Accepted Solutions
SC_TK
12-Amethyst
(To: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 

View solution in original post

1 REPLY 1
SC_TK
12-Amethyst
(To: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 

Announcements



Top Tags