Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.

Controlling Textbox size with iLogic.

Anonymous

Controlling Textbox size with iLogic.

Anonymous
Not applicable

How do you control the font size of multiple textboxes in a single sketch with iLogic?

 

Crazy, right?

 

Okay iLogic and VBA gurus, I think I need your help.  I have an interesting challenge I'm working on.  I've spent that past couple of weekdays working through this on my own but I've exceeded my iLogic and/or my VBA skills.

 

I'm working on a wrench design that has the size and company logo engraved into the handle.  Please review the attached *.ipt file at your convenience.  The thing about the size and logo branding is that it's proportionally scaled depending on the size of the wrench handle, as illustrated below.

 

I have already figured out all of the necessary iLogic rules and forms to make a single 3D Assembly flex so that I can have both imperial and metric size wrenches.  I also figured out how to replace the value of the text so that when I choose a 16mm wrench, the text updates and the Emboss features is right and when I switch it to 5/8" it will also update the text and emboss feature accordingly.

 

The last piece of the puzzle is figuring out how to use iLogic to manipulate the font height in multiple text boxes.  Does anyone have a solution?

 

 

Jay

GW_86142_FRNT_MAIN.jpg

0 Likes
Reply
2,421 Views
15 Replies
Replies (15)

Anonymous
Not applicable

This YouTube video by Clayton Pepmiller of Hagerman & Company illustrates how I plan on manipulating the logo graphics in the center of the *.ipt file.  This facilitates the iLogic parameters necessary to proportionally scale the logo of each size of wrench.

 

https://www.youtube.com/watch?v=hBZU5D7bkqE

 

0 Likes

Anonymous
Not applicable

This forum topic "Emboss File Name on Part" linked below illustrates how I've managed to control the value of the text with a User Parameter.  I found Curtis_Waguespack's last reply particularly helpful.  This allows me to use iLogic to control the value of the text.  This way when I select the 7/8" wrench from the form, or the 8mm wrench, everything changes accordingly.

 

https://forums.autodesk.com/t5/inventor-forum/emboss-file-name-on-part/m-p/3288573/highlight/true#M4...

 

0 Likes

Anonymous
Not applicable

Throughout my research, the closest thing that I have found is post by mikedaniels1009 back in Oct of 2017.  In his "Text size in sketch" forum post, he described his problem being that the degree symbol on his 10° text value was disappearing after he updated the text size.

 

mikedaniels1009 figured out how use iLogic rules and a form to update the textsize for a single textbox in his sketch.  That's great.  

 

I need to do it for all textboxes in a sketch.  There has to be a way to adapt mikedaniels1009 iLogic code to do it.

 

https://forums.autodesk.com/t5/inventor-forum/text-size-in-sketch/m-p/7490624/highlight/true#M665316

0 Likes

Anonymous
Not applicable

on the heels of the post "Text size in sketch",  I think I need help modifying the code to suite my needs.  There has to be some sort of repeating function that takes the code below and applies it to each instance of a textbox.

 

For example, the ForEach function.  However, my problem is I don't know iLogic and VBA code well enough to know that for sure.

 

If I'm reading this right, I think that mikedaniels1009 created the IF statement to extract and replace of the text value.  I don't really need that part of the code.  I think I need the rest of it for each instance of textboxes I have in my sketch.

 

_______________________________________________________________________________________________________________________

 

oSketch = ThisDoc.Document.ComponentDefinition.Sketches("NOZZLE #1 ORIENT")
oTextbox = oSketch.TextBoxes(1)

 

  Dim sFormattedtext As String
  Dim theight As Single

 

    theight = DRAWING_SCALE*3
    theight = theight / 10

 

  Dim tstart As Integer
  Dim tend As Integer
  Dim curtext As String

 

    tstart = InStr(oTextbox.Formattedtext, "'>") + 1

 

      If tstart <> 1 Then
        tend = InStr(oTextbox.Formattedtext, "</Style") - 1
        curtext = Mid(oTextbox.Formattedtext, tstart + 1, tend - tstart)
      Else
        curtext = oTextbox.Formattedtext
      End If

 

    sFormattedtext = "<StyleOverride FontSize='" & theight & "'>" & curtext
    sFormattedtext = sFormattedtext & "</StyleOverride>"

 

oTextbox.Formattedtext = sFormattedtext

 

_______________________________________________________________________________________________________________________

0 Likes

Curtis_Waguespack
Consultant
Consultant

Hi @Anonymous,

 

I didn't look at the examples you gave (other than just a glance), but I think this is what you're after.

 

The attached example file has a sketch called Sketch2 that has two text boxes in it. There are 2 user parameters that are tied to an ilogic form that are used to get the font size from the user, and then the rule updated the formatted text for each text box to adjust each.

 

Also just as a tip, you can search and ask programming questions of this type on the Inventor Customization forum:
http://forums.autodesk.com/t5/Autodesk-Inventor-Customization/bd-p/120

 

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

 

iLogicVb.UpdateWhenDone = True
oSketch = ThisDoc.Document.ComponentDefinition.Sketches("Sketch2")
oTB1 = oSketch.TextBoxes(1)
oTB2 = oSketch.TextBoxes(2)

oTB1.Formattedtext = "<StyleOverride FontSize='" & Text1_Height & "'>" _
& oTB1.Text & "</StyleOverride>" 
oTB2.Formattedtext = "<StyleOverride FontSize='" & Text2_Height & "'>" _
& oTB2.Text & "</StyleOverride>"

 

0 Likes

Anonymous
Not applicable

Hello Curtis.  Thanks for the reply.  Let me check this out and I'll get back to you.

0 Likes

Curtis_Waguespack
Consultant
Consultant

Hi jayportland,

 

It occurred to me that maybe the goal was to set all text boxes in the sketch to use the same font size in which case this example would be more efficient.

 

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

 

iLogicVb.UpdateWhenDone = True
oSketch = ThisDoc.Document.ComponentDefinition.Sketches("Sketch2")


For Each oTextBox In oSketch.TextBoxes
	oTextBox.Formattedtext = "<StyleOverride FontSize='" & Text_Height & "'>" _
	& oTextBox.Text & "</StyleOverride>"
Next

 

Anonymous
Not applicable

Yes, this second reply is super promising.  I've almost dialed this one in.  I'll post back later.

0 Likes

Anonymous
Not applicable

Curtis this is so CLOSE to being my complete solution.  It's like 90% there.  I need two more things things.  One of them is the variable in RED needs to be replaced with a user parameter that is my text container.  How do I specify a User Parameter in that line of code?  Do I just type the name of the user parameter in there?  

 

 

iLogicVb.UpdateWhenDone = True
oSketch = ThisDoc.Document.ComponentDefinition.Sketches("Sketch2")


For Each oTextBox In oSketch.TextBoxes
	oTextBox.Formattedtext = "<StyleOverride FontSize='" & Text_Height & "'>" _
	& oTextBox.Text & "</StyleOverride>"
Next

 

 

0 Likes

Anonymous
Not applicable

@Anonymous wrote:

Curtis this is so CLOSE to being my complete solution.  It's like 90% there.  I need two more things things.  One of them is the variable in RED needs to be replaced with a user parameter that is my text container.  How do I specify a User Parameter in that line of code?  Do I just type the name of the user parameter in there?  

 

 

iLogicVb.UpdateWhenDone = True
oSketch = ThisDoc.Document.ComponentDefinition.Sketches("Sketch2")


For Each oTextBox In oSketch.TextBoxes
	oTextBox.Formattedtext = "<StyleOverride FontSize='" & Text_Height & "'>" _
	& oTextBox.Text & "</StyleOverride>"
Next

 

 


Or better yet, is there a way to omit the text values and only change the text size?

0 Likes

Anonymous
Not applicable

Yes, I got it!!!  I replaced the variable below in RED with the proper syntax for the User Parameter in Green.

 

 

    oTextBox.Formattedtext = "<StyleOverride FontSize='" & Text_Height & "'>" & oTextBox.Text & "</StyleOverride>"
    oTextBox.Formattedtext = "<StyleOverride FontSize='" & Text_Height & "'>"+TextSizeIndicator+"</StyleOverride>"

 

Thanks to GSE_Dan_A who posted "Why is Text Size NOT a Parameter???" back in March of 2013, I saw his iLogic code had that already covered and when I tried to use it in my application it worked out just fine.

 

https://forums.autodesk.com/t5/inventor-forum/why-is-text-size-not-a-parameter/m-p/3817895/highlight...

 

0 Likes

Curtis_Waguespack
Consultant
Consultant

Edit: noticed you'd replied as I was typing.... it looks like you got it working, so you might just disregard this post 

 

Hi jayportland,

 

Both of my previous examples just reuse the existing text value. 

 

I'm using Inventor 2017 at the moment, so I wasn't able to see how your sketches and embossed text were set up, but see the attached file for a more complete example, of how this might be done. 

 

In this example the text box values of Sketch2 are being set to use the parameter called WrenchSize. The Sketch3 text box value is static.


Additionally, the length, width, text fonts and so on are being scaled off of the WrenchSize parameter. 

 

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

Anonymous
Not applicable

Okay, I'm almost done with this one.  The last thing I need is to use this iLogic rule below at the assembly level as opposed to the part level.  I think the key is in the "ThisDoc" argument, but I'm not 100% sure?  I need the rule at the assembly level to tell it to look at my "Handle.ipt" file and find "Sketch2".  

 

I think I need to replace Document with "Handle".  Does that sound right to you guys?

 

iLogicVb.UpdateWhenDone = True

oSketch = ThisDoc.Document.ComponentDefinition.Sketches("Sketch2")

For Each oTextBox In oSketch.TextBoxes
	oTextBox.Formattedtext = "<StyleOverride FontSize='" _
& Text_Height & "'>"+TextSizeIndicator+"</StyleOverride>"
Next
0 Likes

Anonymous
Not applicable

Wow, what a furious whirlwind of iLogic madness over the past couple of days.

 

LOL

 

@Curtis_Waguespack,

Thank you so much for all your help yesterday.  You have no idea how incredibly helpful that was.  Looking back at this forum thread, there were actually a couple of instances where, had I taken more time to think about your replies and your codes, I should have realized that they already answered some of my questions.

 

Whew!!!

 

I got my wrench design working properly with iLogic controlling everything I needed.  My design continues to be sound and is working exactly as expected.

 

Perhaps later this week I'll find some time to post a video of how I managed to solve this challenge I was facing.

 

Thanks everyone.

0 Likes

Curtis_Waguespack
Consultant
Consultant

Hi @Anonymous

 

Glad to hear it's all working, Just noticed the previous post about how to get it working from the assembly. Post back if you still need suggestions on that. 

 

Look forward to the video!

 

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

0 Likes