How get Center point in iLogic sketch?

How get Center point in iLogic sketch?

frantisek_kochan
Explorer Explorer
96 Views
1 Reply
Message 1 of 2

How get Center point in iLogic sketch?

frantisek_kochan
Explorer
Explorer

Hi,

I want to make fully constraint sketch in ipart. So manualy there is predrawn Central point, but if I use "oCompDef.Sketches.Add(oCompDef.WorkPlanes(3))" there is none. So I trying to find way to get him or make him to fully constraint sketch.

 

sub createSkeletonBox()
	'===============Parameters===============
	Dim Vyska = createUserParameter("Vyska", 600, "mm").Value
	Dim Sirka = createUserParameter("Sirka", 450, "mm").Value
	Dim Hloubka = createUserParameter("Hloubka", 400, "mm").Value

	Dim dX = Sirka/2
	Dim dY = Hloubka

	'===============Definitions===============
	Dim oCompDef as PartComponentDefinition
	oCompDef = ThisDoc.Document.ComponentDefinition

	Dim tg As TransientGeometry
	tg = ThisApplication.TransientGeometry

	'===============Work===============

	'===Create skeletonSketch===
	Dim oSketch As PlanarSketch
	oSketch = oCompDef.Sketches.Add(oCompDef.WorkPlanes(3))
	oSketch.name = "skeletonSketch"
	
	Dim lines As Inventor.SketchLines = oSketch.SketchLines
	Dim points As Inventor.SketchPoints = oSketch.SketchPoints
	Dim constr As Inventor.GeometricConstraints = oSketch.GeometricConstraints

	Dim CenterPoint = points.Add(tg.CreatePoint2d(0, 0), False) '??????????????
	'===Points===
	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)

	'===Draw skeletonSketch===
		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))

	'===Constraints===
	constr.AddHorizontal(line0)
	constr.AddHorizontal(line2)
	constr.AddVertical(line1)
	constr.AddVertical(line3)

	'===Dimensions===
	oSketch.DimensionConstraints.AddTwoPointDistance(point_array(0), point_array(1), DimensionOrientationEnum.kHorizontalDim, tg.CreatePoint2d(0, -2)).Parameter.Expression = "Sirka"
	oSketch.DimensionConstraints.AddTwoPointDistance(point_array(1), point_array(2), DimensionOrientationEnum.kVerticalDim, tg.CreatePoint2d(-2, 0)).Parameter.Expression = "Hloubka"
	'oSketch.DimensionConstraints.AddTwoPointDistance(point_array(0), CenterPoint, DimensionOrientationEnum.kHorizontalDim, tg.CreatePoint2d(0, -2)).Parameter.Expression = dX
	'oSketch.DimensionConstraints.AddTwoPointDistance(point_array(0), CenterPoint, DimensionOrientationEnum.kVerticalDim, tg.CreatePoint2d(0, -2)).Parameter.Expression = dY
	
	'===Create a profile===
	Dim oProfile As Profile
    oProfile = oSketch.Profiles.AddForSolid

	'===Create a base extrusion===
	'Dim oExtrude As ExtrudeFeature
	'oExtrude = oCompDef.Features.ExtrudeFeatures.AddByDistanceExtent(oProfile, "Vyska", kPositiveExtentDirection, kNewBodyOperation)
	'oExtrude.SurfaceBodies(1).Name = "@Skeleton"
	'oExtrude.name = "skeletonExtrude"

end sub

2025-08-08_14-43-12.png

 

 

0 Likes
Accepted solutions (1)
97 Views
1 Reply
Reply (1)
Message 2 of 2

Andrii_Humeniuk
Advisor
Advisor
Accepted solution

Hi @frantisek_kochan .
You need to make a projection of the Origin Point onto your sketch. When creating a sketch manually, this happens automatically, but when programming, you need to make the projection as a separate action. I suggest doing it like this:

Dim CenterPoint = points.Add(oSketch.ModelToSketchSpace(oSketch.OriginPointGeometry), False) '??????????????
constr.AddGround(CenterPoint)

Or you can do a projection using AddByProjectingEntity(). Example:

Dim CenterPoint = oSketch.AddByProjectingEntity(oCompDef.WorkPoints(1))

Andrii Humeniuk - CAD Coordinator, Autodesk Certified Instructor

LinkedIn | My free Inventor Addin | My Repositories

Did you find this reply helpful ? If so please use the Accept as Solution/Like.

EESignature