Community
Inventor Forum
Welcome to Autodesk’s Inventor Forums. Share your knowledge, ask questions, and explore popular Inventor topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Adding Font information to sketch

14 REPLIES 14
Reply
Message 1 of 15
Anonymous
870 Views, 14 Replies

Adding Font information to sketch

Is it possible to state what font is being used on an model, on a sketch?

 

I have a silk-screened panel, and I want to link/state the font that was used in the model, within the sketch.

14 REPLIES 14
Message 2 of 15
ing_manuellucena
in reply to: Anonymous

but how do you wanna do it?

 

by iLogic, you needed in a report, a message box, in a .idw file can you been more explicit

 

i guess you could, but how do you needed is other history

Ing. Manuel Lucena
Message 3 of 15
Curtis_Waguespack
in reply to: Anonymous

hi mtofts,

 

Here's an example that gets the font for a named sketch and pushes it to a custom iProperty.

 

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

 

oDoc = ThisDoc.Document
Dim oSketches As Inventor.PlanarSketches 
Dim oSketch As PlanarSketch 
Dim oSketchToGet As String
oSketchToGet = "Sketch1"

oSketches = oDoc.ComponentDefinition.Sketches
For Each oSketch In oSketches
	If oSketch.Name = oSketchToGet Then
		'get text font
        oFont = oSketch.TextBoxes.Item(1).Style.Font
		MessageBox.Show(oFont, "iLogic")
		'write font to iProperty
		iProperties.Value("Custom", "FontName") = oFont
		Exit For
   	End If
Next
Message 4 of 15
mcgyvr
in reply to: Anonymous


@Anonymous wrote:

Is it possible to state what font is being used on an model, on a sketch?

 

I have a silk-screened panel, and I want to link/state the font that was used in the model, within the sketch.


What is the intent of doing so?

When the screen is produced they don't need to know nor care what font was used as whatever you provide is printed onto clear film and burned into the emulsion.. 

 

You can obviously edit a sketch and find that information out if you needed to..

 

You could modify the name of the sketch feature in the model browser to say "Silkscreen Text - Arial Font" too.. 

 

Not knowing the what/why of your request makes providing a valid solution kind of difficult.. (hit/miss/guess)

I do TONS of silkscreening on faceplates,etc.. so I'm just wondering what benefit this would have for you.. 



-------------------------------------------------------------------------------------------
Inventor 2023 - Dell Precision 5570

Did you find this reply helpful ? If so please use the Accept Solution button below.
Maybe buy me a beer through Venmo @mcgyvr1269
Message 5 of 15
Anonymous
in reply to: mcgyvr

We are currently in a stupid situation:

 

Our screen printing is done for a company that wants it sent to them as a .pdf (moronic, I know. Drawing, and then redrawing is not only a waste of time, but also a massive place for errors). However, I'm not the boss here, and I have to accept their choice.

 

 

All I need is a text box which shows the font, and size. However, if I could find a way to do this which is linked; I could change the font (which we may do in the future. We use an old'ish font type), and it would update automatically.

 

How I get to this 'text box with font name and size' is down to artistic freedom.

Message 6 of 15
mcgyvr
in reply to: Anonymous


@Anonymous wrote:

We are currently in a stupid situation:

 

Our screen printing is done for a company that wants it sent to them as a .pdf (moronic, I know. Drawing, and then redrawing is not only a waste of time, but also a massive place for errors). However, I'm not the boss here, and I have to accept their choice.

 

 

All I need is a text box which shows the font, and size. However, if I could find a way to do this which is linked; I could change the font (which we may do in the future. We use an old'ish font type), and it would update automatically.

 

How I get to this 'text box with font name and size' is down to artistic freedom.


I'm still not following/grasping but..

 

Maybe what I do for silkscreening will help..

I will create an idw with a view of the faceplate I need to silkscreen on..

I save copy as and save it as an autocad drawing

I open that drawing in autocad and add all the text/shapes,etc.. that I need (doing it in autocad is much easier IMO for this specific type of work.. Its the ONLY thing I use Autocad for now)

I put all the text on my "silkscreen" layer and then have other information that I want to show up on the silkscreen (a box with the scale/part number/date/revision,etc.. you could put your font information or whatever there too,etc.. on a different layer)

From that Autocad drawing I make a PDF which includes everything that is burned on the actual screen.. This PDF is sent to the company that makes our screens and they print that PDF to a clear film and make the screen... PDF works great for this..

 

So now that I have my "artwork" done I then create a new part in Inventor and insert that "silkscreen" layer only into a sketch.. Then I extrude all the font .001" high (using an excellent ilogic routine from Curtis that I will post in a second that selects everything at once vs me picking each profile which can take a long time)

My silkscreen layer will include all the screenprinted stuff plus 2 "targets" that are used to constrain that properly to the faceplate..

 

Then I simply insert that part into an assembly of my faceplate part + the silkscreen part and voila.. works great..

 

So maybe that will help you..

I've spent a lot of time figuring out how to do screenprinting,etc.. in Inventor as I do quite a bit and this is the best process I've found.. 

As I stated your font information could easily just be text (on a different layer) right in the autocad file..

If the font ever needs to change thats also a simple 1 click step to globally change everything then you would just redo the insert/extrude in Inventor..

 



-------------------------------------------------------------------------------------------
Inventor 2023 - Dell Precision 5570

Did you find this reply helpful ? If so please use the Accept Solution button below.
Maybe buy me a beer through Venmo @mcgyvr1269
Message 7 of 15
Curtis_Waguespack
in reply to: Anonymous

Hi mtofts,

 

I used to have to create these simple drawings for labels and we put the font and size info on the drawing, so the person creating the labels could use that info for initial setup, and/or verification.

 

So how about this:

  • We'll create an iLogic rule that runs from your drawing file and it will look at the model file that is used in View1 of the drawing.
  • Then it will look for a named sketch, or a named feature, or however you can best identify the feature that contains the sketch that contains the font you're interested in.
  • Then we'd find the font, and write that to a sketched symbol on the drawing sheet.
  • We'd set that up to run each time the drawing is saved.

I'd recommend setting this up as a single external iLogic rule that runs on every drawing file when it is saved. That rule looks for certain things ( in this case, it would look for the sketched symbol) and if it finds it, it runs the font rule (or the font code in that rule.

 

If that sounds interesting post back and I'll work up a simple example.

 

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

Message 8 of 15
mcgyvr
in reply to: mcgyvr

Oh and here is the ilogic routine that ^^^that guy up there wrote a while back.. 

Its saved me TONS of time when multiple profiles need to be selected for an extrusion..

 

If TypeOf ThisApplication.ActiveEditObject Is Sketch Then
'Do nothing
Else
MessageBox.Show("Activate a Sketch First then Run this Rule", "ilogic")
Return
End If

Dim oPartDoc As PartDocument
oPartDoc = ThisApplication.ActiveDocument

Dim oCompDef As PartComponentDefinition
oCompDef = oPartDoc.ComponentDefinition

Dim oSketch As PlanarSketch
oSketch = ThisApplication.ActiveEditObject 

' Create a profile.
Dim oProfile As Profile
On Error Goto NoProfile
oProfile = oSketch.Profiles.AddForSolid

'get user input
oDistance = InputBox("Enter Extrude Distance", "iLogic", ".001 in")
oDirection  = InputRadioBox("Select Extrude Direction", "Up (+)", "Down (-)", True, Title := "iLogic")
oJoinOrCut  = InputRadioBox("Select Extrude Solution", "Join", "Cut", True, Title := "iLogic")

If oDirection = True Then
oDirection = kPositiveExtentDirection 
Else
oDirection = kNegativeExtentDirection
End If

If oJoinOrCut = True Then
oJoinOrCut = kJoinOperation
Else
oJoinOrCut = kCutOperation
End If

' Create an extrusion 
Dim oExtrude As ExtrudeFeature
On Error Goto NoExtrude
oExtrude = oCompDef.Features.ExtrudeFeatures.AddByDistanceExtent( _
oProfile, oDistance, oDirection, oJoinOrCut)

ThisApplication.CommandManager.ControlDefinitions.Item("FinishSketch").Execute

iLogicVb.UpdateWhenDone = True

Exit Sub

NoProfile:
MessageBox.Show("No closed profile found", "iLogic")
Return

NoExtrude:
MessageBox.Show("No extrusion created, check your inputs.", "iLogic")
Return


-------------------------------------------------------------------------------------------
Inventor 2023 - Dell Precision 5570

Did you find this reply helpful ? If so please use the Accept Solution button below.
Maybe buy me a beer through Venmo @mcgyvr1269
Message 9 of 15
Anonymous
in reply to: mcgyvr

Wow, looks like a lot of coding for my level....

 

I know it may be a bit of a liberty, but I've attached a basic 'label' for an example.

 

Any chance you could use it for an example to get me started?

 

Thanks

Message 10 of 15
mcgyvr
in reply to: Anonymous


@Anonymous wrote:

Wow, looks like a lot of coding for my level....

 

I know it may be a bit of a liberty, but I've attached a basic 'label' for an example.

 

Any chance you could use it for an example to get me started?

 

Thanks


I'd be happy to.. But I'm not sure what you want from that file you posted ???

Are you just looking for a quick way to essentially throw a leader on it and it magically knows the font size in the drawing?

It would be super easy to just write your font size as a custom parameter in the part and you can easily pull that into a drawing automatically..

 

Please provide more information on what you would like to happen? 

Maybe like an "It would be great if X would happen" or something like that.. 



-------------------------------------------------------------------------------------------
Inventor 2023 - Dell Precision 5570

Did you find this reply helpful ? If so please use the Accept Solution button below.
Maybe buy me a beer through Venmo @mcgyvr1269
Message 11 of 15
Anonymous
in reply to: mcgyvr

I really thought the syntax that I used to explain my self was quite clear...

 

I want the font name and size, that is used on the label, to be displayed on the drawing. I want them to be linked via some parameter. This is because we are potentially having a font change in the near future, and I don't want to have to manually change them all.

 

If I can 'magically' get the appearance to show on the drawing, then why not font? If it cannot be done, then just say so. Please stop being rude/obtuse (I'm not sure which one at the moment). I am only asking a question.

Message 12 of 15
mcgyvr
in reply to: Anonymous

umm.. Sorry if you felt I was being rude or something.. I was not at all.. I was simply attempting to get a bit more information so it was clear what direction we were headed in.. 

 

I'm not sure of a good way to link the font size field to a user parameter (it doesn't accept parameters but only a numerical value).. I'd expect that may be possible with ilogic but I'm not sure.. So I will bow out at this point.. 



-------------------------------------------------------------------------------------------
Inventor 2023 - Dell Precision 5570

Did you find this reply helpful ? If so please use the Accept Solution button below.
Maybe buy me a beer through Venmo @mcgyvr1269
Message 13 of 15
mcgyvr
in reply to: mcgyvr


@mcgyvr wrote:

I'd expect that may be possible with ilogic but I'm not sure.. 


And it is.. 

Open your label.ipt file..

Create a new user parameter of "TEXTHEIGHT" 

Create a new ilogic rule and paste this into it..

Now the text height is driven by that user parameter..

oSketch = ThisDoc.Document.ComponentDefinition.Sketches("Sketch2")
oTextbox = oSketch.TextBoxes(1)

Dim sFormattedtext As String
Dim theight As Single

theight = TEXTHEIGHT
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

I got that from here..

http://microconcepts.typepad.com/design_automation/2015/05/change-text-height-with-ilogic-rule.html

 



-------------------------------------------------------------------------------------------
Inventor 2023 - Dell Precision 5570

Did you find this reply helpful ? If so please use the Accept Solution button below.
Maybe buy me a beer through Venmo @mcgyvr1269
Message 14 of 15
Daniel248
in reply to: mcgyvr

There is more than meets the eye in the OP example:

 

1) My computer does not have the OP’s font installed, and therefore is unable to recognise it: If I open the IPT and hover the mouse over the Sketch2 containing the text, we can see that the text and relevant extrusion do not align properly:

 

New Picture (2).png

 

 

2) If I edit the text and highlight a portion of it, we can see that the font is not being recognised;

 

New Picture (18).png

 

 

3) If I run that iLogic Rule it will work (in so far as changing the text size according to the parameter) but it will also change the Font (to the default - Tahoma, in my case).

 

Whenever I send files to the Silkscreen Printers, I send them as solid hatch filled profile in DXF format at the required size, 1:1 scale, with 0 thickness lines or polylines, without any fonts embedded (or send a PDF version of that DXF, or even Gerber format for laser printing, if needed). That way, all mistakes, errors, or extra work (related to fonts) can be avoided.

 

Sorry if this doesn’t help much the OP with automating / documenting the changes in font and its size, but I hope it helps a bit with clarifying where errors might occur when someone tries to reproduce a Logo, text or similar that uses uncommon fonts.

Message 15 of 15
Curtis_Waguespack
in reply to: Anonymous

Hi mtofts,

 

I'm a bit behind in the discussion, but here is an iLogic rule that you can run from your drawing ( I used part of what mcgyvr posted from the blog link).

 

  • It looks at the view1 and finds the model file from that
  • then it looks at that file for a sketch called "Engraved Text". ( Change that as needed, just make sure the part sketch has the name same as the code.)
  • Then it gets the text value, font name, and font size
  • Then it creates a sketch in the drawing file, and writes those values to a textbox at an insert point x:4,y:4
  • You can then reposition the sketch as needed

Post back if this doesn't work or you need some tweaks to it.

 

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

 

Edit: I made a quick update to handle the situation that Daniel248 mentioned, where the font is not present (which returned an error).

 

'defines the named sketch
'to work with in the part model
Dim oSketchToGet As String
oSketchToGet = "Engraved Text"

'get the model used in the first 
'view of this drawing
oDoc = ThisDrawing.ModelDocument

Dim oSketches As Inventor.PlanarSketches 
oSketches = oDoc.ComponentDefinition.Sketches
Dim oSketch As PlanarSketch 
Try 
oSketch = oSketches(oSketchToGet)
Catch
MsgBox("Error: Check that the model file has a sketched named: "  & oSketchToGet)
Return
End Try

'assumes only one text box in sketch
oFormattedText = _
oSketch.TextBoxes.Item(1).FormattedText 

Dim iStart As Integer
Dim iEnd As Integer
Dim oText As String

'find text value
iStart = InStr(oFormattedText, "'>") + 1
iEnd = InStr(oFormattedText, "</Style") - 1
oText = Mid(oFormattedText, iStart + 1, iEnd - iStart)

'find font
iStart = InStr(oFormattedText, "Font='") + 5
If iStart > "5" Then
iEnd = InStr(iStart+1,oFormattedText, "'") 
oFont = Mid(oFormattedText, iStart+1, iEnd-1 - iStart)
Else
oFont = "?"
End If

'find font size
iStart = InStr(oFormattedText, "FontSize='") + 9
If iStart > "9" Then
iEnd = InStr(iStart+1,oFormattedText, "'") 
oFontSize = Mid(oFormattedText, iStart+1, iEnd-1 - iStart)
Else
oFontSize = "?"
End If

'''now create a text on the drawing
' Set a reference to the drawing document.
' This assumes a drawing document is active.
Dim oDrawDoc As DrawingDocument
oDrawDoc = ThisApplication.ActiveDocument

' Create a new sketch on the active sheet.
Dim oDSketch As DrawingSketch
oDSketch = oDrawDoc.ActiveSheet.Sketches.Add

' Open the sketch for edit 
oDSketch.Edit

Dim oTG As TransientGeometry
oTG = ThisApplication.TransientGeometry

Dim oTextBox As TextBox
'create string
sText = "Text Value: " & oText _
& vbLf & "Font: " & oFont _
& vbLf &  "Font Size: " & oFontSize
'create text box on drawing at x:4, y:4
oTextBox = oDSketch.TextBoxes.AddFitted _
(oTG.CreatePoint2d(4, 4), sText)
'exit sketch
oDSketch.ExitEdit

 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Technology Administrators


Autodesk Design & Make Report