Message 1 of 16
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello. I found this bit of code and tried modifying it to my needs. I'm not sure what I'm missing but it doesn't seem to work. I'm not sure if I'm using GeomIntent Correctly. My workflow is below. Thanks for your help!
WorkPoints
WorkPointProxY
Create Sketch
Edit Sketch
Center Marks
CenterMarks to WorkPointProxy
Geometry Intent
CreatePoint2D
Create Line
Constrain Line
'Get the first two work points (WorkPoints.Item(1) is the origin)
Dim oWorkPoint1 As Inventor.WorkPoint
Dim oWP2 As Inventor.WorkPoint
Set oWorkPoint1 = GetDocWPt(oSubOcc.Definition.Document, "Center Point")
Set oWP2 = GetDocWPt(oSubOcc.Definition.Document, "POINT FLOOR OUT")
'Create a proxy for the two work points
Dim oWorkPointProx1 As Inventor.WorkPointProxy
Dim oWorkPointProx2 As Inventor.WorkPointProxy
Call oSubOcc.CreateGeometryProxy(oWorkPoint1, oWorkPointProx1)
Call oSubOcc.CreateGeometryProxy(oWP2, oWorkPointProx2)
'' 'Include the work points in the drawing view
' Call oView.SetIncludeStatus(WorkPointProx1, True)
' Call oView.SetIncludeStatus(oWorkPointProx2, True)
'
' oView.SetVisibility oWorkPointProx1, False
' oView.SetVisibility oWorkPointProx2, False
Dim oDrawingSketch As DrawingSketch
Dim oLine As SketchLine
Set oDrawingSketch = oView.Sketches.Add
Call oDrawingSketch.Edit
'Now we need to find the two centermarks that represent the work point proxies
Dim oCenterMark1 As Inventor.Centermark
Dim oCenterMark2 As Inventor.Centermark
Dim oCenterMark As Inventor.Centermark
For Each oCenterMark In oSheet.Centermarks
If oCenterMark.Attached Then
If oCenterMark.AttachedEntity Is oWorkPointProx1 Then
Set oCenterMark1 = oCenterMark
ElseIf oCenterMark.AttachedEntity Is oWorkPointProx2 Then
Set oCenterMark2 = oCenterMark
End If
End If
Next
Dim oTG As TransientGeometry: Set oTG = ThisApplication.TransientGeometry
'From the two work points, we create the geometry intent
Dim oGeomIntent1 As Inventor.GeometryIntent
Dim oGeomIntent2 As Inventor.GeometryIntent
Set oGeomIntent1 = oSheet.CreateGeometryIntent(oCenterMark1, Inventor.kPoint2dIntent)
Set oGeomIntent2 = oSheet.CreateGeometryIntent(oCenterMark2, Inventor.kPoint2dIntent)
Dim oPointOne As Point2d
Set oPointOne = oTG.CreatePoint2d(oGeomIntent1.PointOnSheet.X, oGeomIntent1.PointOnSheet.Y)
Dim oPointTwo As Point2d
Set oPointTwo = oTG.CreatePoint2d(oGeomIntent2.PointOnSheet.X, oGeomIntent2.PointOnSheet.Y)
Dim oPointStart As Point2d
Set oPointStart = oView.SheetToDrawingViewSpace(oPointOne)
Dim oPointEnd As Point2d
Set oPointEnd = oView.SheetToDrawingViewSpace(oPointTwo)
Set oLine = oDrawingSketch.SketchLines.AddByTwoPoints(oPointStart, oPointEnd)
oLine.Construction = True
Call oDrawingSketch.GeometricConstraints.AddHorizontal(oLine)
Call oDrawingSketch.ExitEdit
Tiffany Hayden
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
Solved! Go to Solution.