Message 1 of 5
Dimension Sketch with iLogic

Not applicable
08-14-2019
03:42 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I was wondering how one might go about dimensioning a line length inside of a sketch as a parameter in iLogic.
Currently my code does the following:
Creates a sketch:
Dim planeXY = oCD.WorkPlanes.Item(3)'1 for yz, 2 for xz, 3 for xy Dim my_sketch As Sketch my_sketch = oCD.Sketches.Add(planeXY) my_sketch.Name = "Mounting Holes" ' name sketch my_sketch.EditCreates parameters
Creates points:
Dim tg As Inventor.TransientGeometry = ThisApplication.TransientGeometry Dim lines As Inventor.SketchLines = my_sketch.SketchLines Dim points As Inventor.SketchPoints = my_sketch.SketchPoints Dim point_array(3) As Inventor.SketchPoint point_array(0) = points.Add(tg.CreatePoint2d(0, 0), False) point_array(1) = points.Add(tg.CreatePoint2d(4, 0), False) point_array(2) = points.Add(tg.CreatePoint2d(4, 4), False) point_array(3) = points.Add(tg.CreatePoint2d(0, 4), False)
Connects those points to form a square:
'connect sketch points Dim line0 = lines.AddByTwoPoints(point_array(0), point_array(1)) Dim line1 = lines.AddByTwoPoints(point_array(1), point_array(2)) Dim line2 = lines.AddByTwoPoints(point_array(2), point_array(3)) Dim line3 = lines.AddByTwoPoints(point_array(3), point_array(0))
Adds geometric constraints:
'constrain geometry Dim constr As Inventor.GeometricConstraints constr = my_sketch.GeometricConstraints 'horizontal constraints constr.AddHorizontal(line0) constr.AddHorizontal(line2) 'vertical constraints constr.AddVertical(line1) constr.AddVertical(line3) 'equal constraints constr.AddEqualLength(line0, line1) 'dimension lines????????????? Dim dimension As Inventor.DimensionConstraints dimension = my_sketch.DimensionConstraints
But how do you dimension that line using the values defined in the parameters? I essentially want the user to be prompted to input a number as a parameter, and have that parameter be applied to the respective line. I have attached a picture of what I am hoping the end result to be.
Thank you!