Ilogic Addcoincident of two points doesn't work

Ilogic Addcoincident of two points doesn't work

Anonymous
Not applicable
650 Views
2 Replies
Message 1 of 3

Ilogic Addcoincident of two points doesn't work

Anonymous
Not applicable

Hi i am trying to automate a sketch with ilogic. 

Now i already got to draw the circles but now i want to constrain them. 

Somehow i cannot constrain the two centerpoint of two circles together. 

i dont need them to merge or anything, they just need to be in the same place. 

imports system.IO
Dim Def As PartComponentDefinition = ThisDoc.Document.Componentdefinition
Dim plane As WorkPlane
Dim i As Integer =-2 
For Each plane In Def.WorkPlanes
	i = i + 1
Next
Dim WPlane As WorkPlane = Def.WorkPlanes.AddByPlaneAndOffset(Def.WorkPlanes("YZ plane"), (60.3 / 20) + 0.2)
WPlane.Name = "Plane " & i

Dim oSketch As Sketch = Def.Sketches.Add(WPlane)
oSketch.Name = "Hole " & i
oSketch.Edit
Dim oTG As TransientGeometry = ThisApplication.TransientGeometry

	'create base point at 0,0
Dim Bp As SketchPoint = oSketch.SketchPoints.Add(oTG.CreatePoint2d(0, 0))
	'create circle insertionpoint
Dim Cp As Point2d = oTG.CreatePoint2d(5, 0)
	'project origin point
'Dim Origin As SketchPoint = oSketch.AddByProjectingEntity(def.WorkPoints.Item(1))
	'create first circle
Dim oCircle As SketchCircle
oCircle = oSketch.SketchCircles.AddByCenterRadius(Cp, (13.2 / 10))
	'create second circle
Dim oCircle1 As SketchCircle
oCircle = oSketch.SketchCircles.AddByCenterRadius(oCircle.CenterSketchPoint, ((13.2-2) / 10))

Dim Constraints As GeometricConstraints = oSketch.GeometricConstraints
Trace.WriteLine("Ground Bp")
	'constriant base point
Constraints.AddGround(Bp)
Trace.WriteLine("horizontal")
	'constraint first circle horizontal to base point
Constraints.AddHorizontalAlign(Bp, oCircle.CenterSketchPoint)
Trace.WriteLine("coincident")
'oCircle1.CenterSketchPoint.Merge(oCircle.CenterSketchPoint)
Constraints.AddCoincident(oCircle.CenterSketchPoint, oCircle1.CenterSketchPoint)
Trace.WriteLine("End code")


Also i found out i cannot do 'addhorizontalalign' with a sketchpoint and a projected point with iloigc, which does work when you do it by hand. 

Does anyone know restrictions or tips when using constraints with ilogic?

 

Kind regards, 

 

Geert

0 Likes
Accepted solutions (1)
651 Views
2 Replies
Replies (2)
Message 2 of 3

Sergio.D.Suárez
Mentor
Mentor
Accepted solution

Hi, I do not understand what you are trying to achieve, however I have corrected your code, you have misplaced the statement that I have highlighted first in red.

 

imports system.IO
Dim
Def As PartComponentDefinition = ThisDoc.Document.Componentdefinition Dim plane As WorkPlane Dim i As Integer =-2 For Each plane In Def.WorkPlanes i = i + 1 Next Dim WPlane As WorkPlane = Def.WorkPlanes.AddByPlaneAndOffset(Def.WorkPlanes("YZ plane"), (60.3 / 20) + 0.2) WPlane.Name = "Plane " & i Dim oSketch As Sketch = Def.Sketches.Add(WPlane) oSketch.Name = "Hole " & i oSketch.Edit Dim oTG As TransientGeometry = ThisApplication.TransientGeometry 'create base point at 0,0 Dim Bp As SketchPoint = oSketch.SketchPoints.Add(oTG.CreatePoint2d(0, 0)) 'create circle insertionpoint Dim Cp As Point2d = oTG.CreatePoint2d(5, 0) 'project origin point 'Dim Origin As SketchPoint = oSketch.AddByProjectingEntity(def.WorkPoints.Item(1)) 'create first circle Dim oCircle As SketchCircle oCircle = oSketch.SketchCircles.AddByCenterRadius(Cp, (13.2 / 10)) 'create second circle Dim oCircle1 As SketchCircle oCircle1 = oSketch.SketchCircles.AddByCenterRadius(oCircle.CenterSketchPoint, ((13.2-2) / 10)) Dim Constraints As GeometricConstraints = oSketch.GeometricConstraints Trace.WriteLine("Ground Bp") 'constriant base point Constraints.AddGround(Bp) Trace.WriteLine("horizontal") 'constraint first circle horizontal to base point Constraints.AddHorizontalAlign(Bp, oCircle.CenterSketchPoint) Trace.WriteLine("coincident") 'oCircle1.CenterSketchPoint.Merge(oCircle.CenterSketchPoint) Constraints.AddCoincident(oCircle.CenterSketchPoint, oCircle1.CenterSketchPoint) Trace.WriteLine("End code") Constraints.AddCoincident(oCircle.CenterSketchPoint, Bp)

 To the latter, add a line that matches the center of the circle and the point you set at the beginning.
I hope this helps in something. Regards


Please accept as solution and give likes if applicable.

I am attaching my Upwork profile for specific queries.

Sergio Daniel Suarez
Mechanical Designer

| Upwork Profile | LinkedIn

0 Likes
Message 3 of 3

Anonymous
Not applicable

Thanks for the solution. 

we use t pulling in pies to weld connectors to headers, something like the following video

https://www.youtube.com/watch?v=rYj7EDZyB8c

we do this a lot so i want to automate the process of modelling this.

 

0 Likes