Ilogic: Add numbers to a ruler

Ilogic: Add numbers to a ruler

pball
Mentor Mentor
549 Views
3 Replies
Message 1 of 4

Ilogic: Add numbers to a ruler

pball
Mentor
Mentor

I'm trying to make a template for a ruler. I could use some help figuring out how to add the numbers in an adaptive fashion. I haven't used iLogic for modeling before so I'm not sure where to start.

 

Attached part is done in 2020.

 

Check out my style edits for the Autodesk forums
pball's Autodesk Forum Style
0 Likes
550 Views
3 Replies
Replies (3)
Message 2 of 4

Michael.Navara
Advisor
Advisor

Hi

Here is sample code for creating TextBoxes in Sketch and modified ruler.ipt (rule included)

This rule creates only text boxes. You need to create engraving manually. It is possible to create it using API, but I omit it.

Number of textboxes depends on ruler length (sketch points count).

 

Dim part As PartDocument = ThisDoc.Document

Dim textSketch As PlanarSketch = part.ComponentDefinition.Sketches("TextSketch")

'Delete existing text boxes
While (textSketch.TextBoxes.Count>0)
	textSketch.TextBoxes(1).Delete
End While

'Create new textboxes to hole center sketch points 
'(This is type of sketch point, not necessary center of hole)
Dim i As Integer = 1
For Each skPoint As SketchPoint In textSketch.SketchPoints
	If Not skPoint.HoleCenter Then Continue For
	
	Dim txtBox As Inventor.TextBox = textSketch.TextBoxes.AddFitted(skPoint.Geometry, i.ToString(),"DEFAULT-ANSI")
	txtBox.VerticalJustification = VerticalTextAlignmentEnum.kAlignTextMiddle
	txtBox.HorizontalJustification = HorizontalTextAlignmentEnum.kAlignTextLeft
	i+=1
Next

 

0 Likes
Message 3 of 4

pball
Mentor
Mentor

Thanks, that helps out a lot.

Check out my style edits for the Autodesk forums
pball's Autodesk Forum Style
0 Likes
Message 4 of 4

pball
Mentor
Mentor

I added some code to extrude the numbers I found from other examples. The first time I ran the code it worked but I cannot get it run subsequent times. Could someone take a look at the internal iLogic rule and fix it up so it can be run over and over without errors. Thanks

Check out my style edits for the Autodesk forums
pball's Autodesk Forum Style
0 Likes