Export Prompt Sketch Symbol Text to a Excel

Export Prompt Sketch Symbol Text to a Excel

AMN3161
Advocate Advocate
1,816 Views
12 Replies
Message 1 of 13

Export Prompt Sketch Symbol Text to a Excel

AMN3161
Advocate
Advocate

So I have a prompt sketch symbol entry with one field used throughout a drawing with different texts but same sketch symbol name, does anyone have a rule to export all of that text to excel document? I am very unfamiliar with sketch prompt entries and not sure how to access its properties

 

thank you for any help

0 Likes
Accepted solutions (1)
1,817 Views
12 Replies
Replies (12)
Message 2 of 13

A.Acheson
Mentor
Mentor

You can look at the symbol object and get the displayed text

Syntax

SketchedSymbol.GetResultTextDefinitionText As TextBox ) As String

 

So if you loop through each Symbol in oActiveSheet.SketchedSymbols and select by name which one you want and retrieve text. 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
0 Likes
Message 3 of 13

AMN3161
Advocate
Advocate

Do you mind posting a quick example of how

 

"SketchedSymbol.GetResultTextDefinitionText As TextBox ) As String"

 

Would be used? I am very novice at this

0 Likes
Message 4 of 13

A.Acheson
Mentor
Mentor

Here is a sample.  Let me know if you understand this and or need more assistance. 

Dim DrawDoc As DrawingDocument = ThisDoc.Document
Dim ActiveSht As Sheet = DrawDoc.ActiveSheet

For Each Sym As SketchedSymbol In ActiveSht.SketchedSymbols
	
	'Get text from first text box
	Dim TxtResult As String = Sym.GetResultText(Sym.Definition.Sketch.TextBoxes(1))
	MessageBox.Show(TxtResult, "Title")
	
Next

 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
0 Likes
Message 5 of 13

AMN3161
Advocate
Advocate

Is the Sym where you call out the symbol name?

0 Likes
Message 6 of 13

J-Camper
Advisor
Advisor
Accepted solution

@AMN3161,

 

@A.Achesonis showing how to loop through all symbols on  the active sheet.  If you want to filter only a specific symbol by name you can modify the rule like this:

Dim DrawDoc As DrawingDocument = ThisDoc.Document
Dim ActiveSht As Sheet = DrawDoc.ActiveSheet
Dim SketchedSymbolName As String = "Your Symbol Name"

For Each Sym As SketchedSymbol In ActiveSht.SketchedSymbols
	If Sym.Definition.Name <> SketchedSymbolName Then Continue For
		
	'Get text from first text box
	Dim TxtResult As String = Sym.GetResultText(Sym.Definition.Sketch.TextBoxes(1))
	MessageBox.Show(TxtResult, "Title")
	
Next
0 Likes
Message 7 of 13

AMN3161
Advocate
Advocate

I see, i understand now


thank you!

0 Likes
Message 8 of 13

A.Acheson
Mentor
Mentor

Once you declare an object as a SketchedSymbol you then have access to all its methods and properties, this becomes apparent when you get a drop down list  after you type " Sym" and start to use this object with "." . Here is the API help for SketchedSymbol. You will find "Name" under properties of Sketch Symbol.

 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
0 Likes
Message 9 of 13

nnakka
Contributor
Contributor
How do i access prompted entry text box for all the symbols in one sheet and enter the values?
if i have 5 instances of same symbol(with prompted entry) in one sheet , i have to edit prompted entry 5 times to fill in values eg. 701,702,703,704,705,

Please help.
Thank you
0 Likes
Message 10 of 13

J-Camper
Advisor
Advisor

@nnakka,

 

You could do something like this:

Dim DrawDoc As DrawingDocument = ThisDoc.Document
Dim ActiveSht As Sheet = DrawDoc.ActiveSheet
Dim SketchedSymbolName As String = "Your Symbol Name"

Dim Instance As Integer = 1
Dim Prefix As String = String.Empty

For Each Sym As SketchedSymbol In ActiveSht.SketchedSymbols
	If Sym.Definition.Name <> SketchedSymbolName Then Continue For
	
	If Prefix = String.Empty Then Prefix = InputBox("Provide prefix for prompted entries in Symbol: " & SketchedSymbolName, "Prefix for Symbol", "Example_")
	
	'Set text from first text box
	Sym.SetPromptResultText(Sym.Definition.Sketch.TextBoxes(1), Prefix & Instance.ToString)
	Instance += 1
	
Next

This is pretty basic and could be refined to be more robust to handle finding the proper textbox by name, but I don't know any of your specific needs.

 

Let me know if you have any questions

 

Message 11 of 13

nnakka
Contributor
Contributor

Thank you so much . it works as i expected it to. 

instance +1 works. only issue is if the number reaches 609 ,next one comes as 6010 as i started with 60 

it gave 601,602.......609 and 6010.

How to change that to 610 ,611 automatic when i run the code?

appreciate the help.

0 Likes
Message 12 of 13

J-Camper
Advisor
Advisor

Try This:

Dim DrawDoc As DrawingDocument = ThisDoc.Document
Dim ActiveSht As Sheet = DrawDoc.ActiveSheet
Dim SketchedSymbolName As String = "Your Symbol Name"

Dim Instance As Integer = 1
Dim Prefix As String = String.Empty

For Each Sym As SketchedSymbol In ActiveSht.SketchedSymbols
	If Sym.Definition.Name <> SketchedSymbolName Then Continue For
	
	If Prefix = String.Empty Then Prefix = InputBox("Provide prefix for prompted entries in Symbol [leave room for 2 digit instances]: " & SketchedSymbolName, "Prefix for Symbol", "Example_")
	
	Dim InstanceAsString As String = Instance.ToString
	If InstanceAsString.Length = 1 Then InstanceAsString = "0" & Instance.ToString
	'Set text from first text box
	Sym.SetPromptResultText(Sym.Definition.Sketch.TextBoxes(1), Prefix & InstanceAsString)
	Instance += 1
	
Next

 

It should create 2 digit instances till 100, then it will be 3 digits.  Let me know if you have any questions

Message 13 of 13

nnakka
Contributor
Contributor

Just Brilliant... Works great.

 

Thanks again.

0 Likes