Script Error in Label

Script Error in Label

Julio_Soto
Advisor Advisor
497 Views
5 Replies
Message 1 of 6

Script Error in Label

Julio_Soto
Advisor
Advisor

I'm trying to write a script for a label for threaded holes.  I just need small holes to be shown as #12, etc., and anything larger as a 3/4" UNC, ect.  My problem comes when I try to use a token in the script that is a fraction. I get this error.  

Julio_Soto_0-1646149363077.png

 

Here is the code

 

%%script(var = %[20,5,5]Diameter
If var = 0.164 Then
display = "#8 UNC"
ElseIf var = 0.19 Then
display = "#10 UNC"
ElseIf var = 0.216 Then
display = "#12 UNC"
Else
display = "%Diameter UNC"
End If
appendstring(display))

 

 

If the unit type for %Diamter is set to decimal then it works. But I don't want decimal, I want fractions with inch symbol. 

 

I think that "Unterminated String Constant" error has to do with the quotation, but I can't get units without the inch symbol even using 

Julio_Soto_0-1646150210315.png

 

0 Likes
498 Views
5 Replies
Replies (5)
Message 2 of 6

Sebastian_Eiche
Mentor
Mentor

I think you're right with the fractional idea.
you could output in fractional, but the internal usage is always metric. So why do you change it?

I would try to add a msgbox to let me show, which is the result of %diameter.
If you want to compare it with specific values, you maybe convert the value by using terms like "valuexy/25.4" ?


Sebastian Eiche
Application Engineer @Mensch und Maschine acadGraph

EESignature

If this information was helpful, please use the Accept as Solution function, this make it easier for other users

Message 3 of 6

Julio_Soto
Advisor
Advisor

I'm not sure what you mean by a message box.

 

Also, it looks like %Diamter is formatted to whatever your project settings are set to. For this drawing, it is set to inches/fractions. So to even use %Diameter in the script I have to force it to a decimal value. The problem is I don't have a way of converting it back to a fraction. I googled this topic and it doesn't seem like an easy task. The script looks big and probably not appropriate for this label. 

0 Likes
Message 4 of 6

Sebastian_Eiche
Mentor
Mentor

with message box I mean, I would use a messagebox to first have a look what the value is about.
I use this to verify if I use the correct phrases like "," or ".", because sometimes it's show in another way later in the label (not often).
In your case I would use a msgbox for diameter:

%%script(var = %[20,5,5]Diameter
msgbox var
appendstring(display))

Sebastian Eiche
Application Engineer @Mensch und Maschine acadGraph

EESignature

If this information was helpful, please use the Accept as Solution function, this make it easier for other users

Message 5 of 6

Julio_Soto
Advisor
Advisor

that can be pretty useful for other things but in my case, it still errors out. If my project settings is set to fractions then %Diameter will cause the script to break and the message box to display nothing.

 

Interestingly enough if I dont' close the parenthesis of the script as I work it out I can see the result of the tokens.

Julio_Soto_0-1646337440895.png

 

as soon as I close the parenthesis the script fails for the reason in my original post. 

 

Thanks for trying to help Sebastian. I reached out to Graitec about this and it looks like they will escalate this to AutoDesk. I'm not hopeful. I suspect this is a problem with AS.

0 Likes
Message 6 of 6

Sebastian_Eiche
Mentor
Mentor

I think this logical because the unit is using a " 
and this is used for defining strings. I would try to delete the last character. 
Here's a small example:

%%script(var = %Diameter
var2=Left(var, len(var)-1)
msgbox var2
appendstring(var2))

Sebastian Eiche
Application Engineer @Mensch und Maschine acadGraph

EESignature

If this information was helpful, please use the Accept as Solution function, this make it easier for other users

0 Likes