Message 1 of 2
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello,
Im a beginner in creating ilogics. I have an issue that I'm hopeful you all can help with.
I'm trying to write an iLogic to create a 3D sketch using work points. I'm able to create work points at the required coordinates and generate the 3D sketch following those coordinates, but I'm unable to make the sketch dependent on the work points (like using a coincident constraint in between 3d sketch point and workpoint). I need it to be such that if I adjust the work point coordinates, the sketch should update or regenerate automatically (If that is not possible im looking for full dimensional constrains w.r.t origin point).
Sub Main() ' Example coordinates (You can replace this with actual points from your model) Dim pathCoordinates As New List(Of Point) pathCoordinates.Add(ThisApplication.TransientGeometry.CreatePoint(0, 0, 0)) pathCoordinates.Add(ThisApplication.TransientGeometry.CreatePoint(10, 10, 0)) pathCoordinates.Add(ThisApplication.TransientGeometry.CreatePoint(20, 20, 20)) ' Create work points first Dim workPoints As List(Of WorkPoint) = CreateWorkPoints(pathCoordinates) ' Create the 3D sketch using the work points Dim oSketch3D As Sketch3D = Create3DSketchWithWorkPoints(workPoints) End Sub ' Function to create work points Function CreateWorkPoints(pathCoordinates As List(Of Point)) As List(Of WorkPoint) Dim oPartDoc As PartDocument = ThisDoc.Document Dim oCompDef As PartComponentDefinition = oPartDoc.ComponentDefinition Dim oWPts As WorkPoints = oCompDef.WorkPoints Dim workPoints As New List(Of WorkPoint) Dim counter As Integer = 1 For Each point As Point In pathCoordinates Dim oWPt As WorkPoint = oWPts.AddFixed(Point) oWPt.Name = "WorkPoint" & counter workPoints.Add(oWPt) counter += 1 Next Return workPoints End Function ' Function to create a 3D sketch with work points Function Create3DSketchWithWorkPoints(workPoints As List(Of WorkPoint)) As Sketch3D Dim oPartDoc As PartDocument = ThisDoc.Document Dim oCompDef As PartComponentDefinition = oPartDoc.ComponentDefinition ' Create Sketch3D Dim oSk3D As Sketch3D = oCompDef.Sketches3D.Add oSk3D.Name = "Sketch3D1" ' Edit sketch oSk3D.Edit ' Create sketch points using work points Dim sketchPoints As New List(Of SketchPoint3D) For Each oWPt As WorkPoint In workPoints ' Create SketchPoint3D using the coordinates of the WorkPoint Dim oSkPt As SketchPoint3D = oSk3D.SketchPoints3D.Add(oWPt.Point) sketchPoints.Add(oSkPt) Next ' Create lines connecting the sketch points For i As Integer = 0 To sketchPoints.Count - 2 oSk3D.SketchLines3D.AddByTwoPoints(sketchPoints(i), sketchPoints(i + 1)) Next ' Exit sketch oSk3D.ExitEdit Return oSk3D End Function
Solved! Go to Solution.