Having text size based on another parameter

Having text size based on another parameter

icebot53
Enthusiast Enthusiast
3,265 Views
18 Replies
Message 1 of 19

Having text size based on another parameter

icebot53
Enthusiast
Enthusiast

Good day Guys,

 

Is there any way that I can have the text size on this part be fixed to another parameter which updates by e.g. the toe board length. 

 

As the toeboard gets bigger, I want to increase the text size.

 

Thanks for the help!

0 Likes
Accepted solutions (1)
3,266 Views
18 Replies
Replies (18)
Message 2 of 19

johnsonshiue
Community Manager
Community Manager

Hi! There might be API or iLogic solution here. But, the most straightforward approach I can think of is to do the following.

 

1) Edit Extrusion3 and change the operation to New Body.

2) Direct Edit -> Body -> pick the text body -> Scale -> Non-uniform -> set Y = 1 and X and Z to the scale associated with parameters.

3) Combine -> Cut -> pick the first solid as base and second body as tool.

 

Many thanks!

 



Johnson Shiue (johnson.shiue@autodesk.com)
Software Test Engineer
Message 3 of 19

Lewis.Young
Collaborator
Collaborator

Hello,

 

Using iLogic, this can be achieved.

  • Lets say the board is 100mm high, and you want the text to always be half the size of that (50mm), create two custom parameters:
  • One parameter should be "BoardHeight" and should be set as 100mm, in this example.
  • The second parameter should be called "TextSize" and should be set as BoardHeight/2
  • Now in your model, go to sketch that defines the board height and change the dimension to be BoardHeight
  • Now go to the manage tab and select "Add Rule" from the iLogic pane.
  • Paste this code in. Where it says "Sketch2", change it to the sketch that contains your text

SyntaxEditor Code Snippet

Dim odoc As PartDocument

odoc = ThisApplication.ActiveDocument

 
Dim osketch As Sketch

'The used sketch name in the extrusion is Text

osketch =odoc.ComponentDefinition.Sketches.Item("Sketch2")

 
osketch.TextBoxes.Item(1).FormattedText ="<StyleOverride FontSize='" & TextSize/10 & "'>" & oSketch.TextBoxes(1).Text & "</StyleOverride>"

 
odoc.Update

Now whenever the BoardHeight parameter is altered, the text size will change accordingly.

 

If you want the text size to be defined differently, for example the board height - 20mm, then change the "TextSize" parameter to be BoardHeight-20mm instead.

 

If you need any more help with this let me know 🙂

 

Lewis Young
Windows 7 x64 - 32GB Ram
Intel Xeon E5-1620 v2 @ 3.70GHz
nVidia Quadro M2000 - 4GB
Inventor Professional 2017.3
Vault Basic 2017

Message 4 of 19

Lewis.Young
Collaborator
Collaborator
Accepted solution

Here's a screencast showing that example in action: https://autode.sk/2wMSVJI

kelly.young has embedded your screencast for clarity.

Message 5 of 19

icebot53
Enthusiast
Enthusiast

Hi Lewis,

 

I like your idea and it seems to work, but the difference is my height won't be changing, but my width will be changing.

 

How would that change the way I apply the rule.

0 Likes
Message 6 of 19

Lewis.Young
Collaborator
Collaborator

Hello,

 

Okay i see, so as the board gets wider what do you want the text to do?

If you're increasing the text size, it will get to a point where the height of the board can't accommodate the text size.

 

Lewis Young
Windows 7 x64 - 32GB Ram
Intel Xeon E5-1620 v2 @ 3.70GHz
nVidia Quadro M2000 - 4GB
Inventor Professional 2017.3
Vault Basic 2017

0 Likes
Message 7 of 19

icebot53
Enthusiast
Enthusiast

I want to have fixed values e.g. if the tblength is 2400 the text size must be 450, iftblength is 2000 text size must be 400.

 

I will manually calculate and place these text size values once.

 

0 Likes
Message 8 of 19

Lewis.Young
Collaborator
Collaborator

Okay that's not a problem, so the width is the same on all boards? if so, what would the width be?

 

Lewis Young
Windows 7 x64 - 32GB Ram
Intel Xeon E5-1620 v2 @ 3.70GHz
nVidia Quadro M2000 - 4GB
Inventor Professional 2017.3
Vault Basic 2017

0 Likes
Message 9 of 19

icebot53
Enthusiast
Enthusiast

Here you are.Capture.JPG

0 Likes
Message 10 of 19

Lewis.Young
Collaborator
Collaborator

Thanks for that.

As you can see, if you keep the width at 210 and increase the text, it will become bigger than the part itself, which i assume you don't want?

A limit would have to be applied so that text size cannot be more than the board height in this case

 

Lewis Young
Windows 7 x64 - 32GB Ram
Intel Xeon E5-1620 v2 @ 3.70GHz
nVidia Quadro M2000 - 4GB
Inventor Professional 2017.3
Vault Basic 2017

0 Likes
Message 11 of 19

icebot53
Enthusiast
Enthusiast

See it isn't technically the height that is the problem. When I add a text to the board, I constrain the 4 corners of the text to the 4 corners of the boards. When the board is 2500 wide, the size 150 text fits fine. But as soon as you decrease the size of the boards, it forces the text into a double line as shown on the picture and then it is off. Can I not make an ilogic rule with an if statement saying, if tblength = 2500 then textsize = 150, if tblength = 2000 then textsize = 120 etc etc?

0 Likes
Message 12 of 19

Lewis.Young
Collaborator
Collaborator

I think part of the problem is that you're using the standard "Text" tool. If you create a sketch line you can use "Geometry Text" to apply text onto lines and then constrain the line in place.

 

Do you want the text to always be in the middle of the board?

 

Also what you've suggested at the end is exactly what i was thinking. If you give me all the tblength and textsize's i will try and create the code to do so!

 

Lewis Young
Windows 7 x64 - 32GB Ram
Intel Xeon E5-1620 v2 @ 3.70GHz
nVidia Quadro M2000 - 4GB
Inventor Professional 2017.3
Vault Basic 2017

0 Likes
Message 13 of 19

icebot53
Enthusiast
Enthusiast

Capture.JPG

0 Likes
Message 14 of 19

icebot53
Enthusiast
Enthusiast

And yes, I want the text to always be in the centre of the board.

0 Likes
Message 15 of 19

Lewis.Young
Collaborator
Collaborator

Okay great, do you have the corresponding text sizes to go with the tblengths?

 

Lewis Young
Windows 7 x64 - 32GB Ram
Intel Xeon E5-1620 v2 @ 3.70GHz
nVidia Quadro M2000 - 4GB
Inventor Professional 2017.3
Vault Basic 2017

0 Likes
Message 16 of 19

Lewis.Young
Collaborator
Collaborator

Sorry i've just realised something! if your intention is to make an iPart for the toe board, then iLogic rules won't run correctly.

 

This is because the iParts embedded table drives the parameters for each factory member, not the rule.

 

I'll have another think and see if i can think of an alternative to doing it manually.

 

Lewis Young
Windows 7 x64 - 32GB Ram
Intel Xeon E5-1620 v2 @ 3.70GHz
nVidia Quadro M2000 - 4GB
Inventor Professional 2017.3
Vault Basic 2017

0 Likes
Message 17 of 19

sjxyz
Enthusiast
Enthusiast

Hi, the code you've given would work perfectly for me, except that I have Text Parameters in my sketch text. Is there any chance you could advise how to re-write it so that the parameters are used? As it is, it uses the values of the parameters at the time the rule is run, but then they're lost. Many thanks!

0 Likes
Message 18 of 19

sandeepMBMV3
Explorer
Explorer

Hi Lewis,

It was very helpful, Thank you so much

0 Likes
Message 19 of 19

cliff.kelly
Participant
Participant

Hello,

I was using a version of this code and it works great, however I have run into one snag.

I want the font to be "Stencil", however run the code it defaults back to "Tahoma".

Are you able to add a line of code that allows me to change font style?

Thanks,

 

0 Likes