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

Dimension constraint positioning

I want create the situaition as in the photo via ilogic. I know how to create a line add the constraints and the dimension constraint. The problem i encountered is postioning the dimension constraint a little above the line and in the middle of the line.

 

Is there anyway to automaticly postion the dimension constraint like in the picture via ilogic for any kind of view  and any line length???? 

 

Here is the code so far:

 

Dim partDoc As PartDocument 
partDoc = ThisApplication.activedocument

Dim partDef As Inventor.PartComponentDefinition 
partDef = partDoc.ComponentDefinition 

'set a reference to the transient geometry collection.
Dim oTransGeom As TransientGeometry
oTransGeom = ThisApplication.TransientGeometry


' Create a new sketch.
Dim oSketch As PlanarSketch 
oSketch = partDef.Sketches.Add(partDef.WorkPlanes.Item(1), False)

oSketch.edit

Dim oOriginSketchPoint As SketchPoint = oSketch.AddByProjectingEntity(PartDef.WorkPoints.Item(1))
oline=oSketch.SketchLines.AddByTwoPoints (oOriginSketchPoint, ThisApplication.TransientGeometry.CreatePoint2d(-100,0))

oSketch.GeometricConstraints.AddHorizontal(oline)
oSketch.DimensionConstraints.AddTwoPointDistance(oline.startSketchPoint,oline.EndSketchPoint, DimensionOrientationEnum.kHorizontalDim,ThisApplication.TransientGeometry.CreatePoint2d(0,oline.Length*0.1))