Message 1 of 3

Not applicable
01-29-2021
12:34 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello,
I have an application where I want to obtain the x,y,z coordinates of a point2d object with respect the origin (Centerpoint) of an inventor part. I tried to use the method the Addfixed method but that only works for a point object. I created a simple example (attached) of an extruded cylinder where I create a sketch and a point2d object of the face of the extruded cylinder. Please find attached file and sample code below.
Thanks!
Sub GetAbsCoordsOfPoint2DObject()
Dim oPDoc As PartDocument
Set oPDoc = ThisApplication.ActiveDocument
Dim oPDef As PartComponentDefinition
Set oPDef = oPDoc.ComponentDefinition
Dim selectedFace As Face
Set selectedFace = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kPartFacePlanarFilter, "Select Face to place feature")
Dim oWkPlanes As WorkPlanes
Set oWkPlanes = oPDef.WorkPlanes
Dim oWkPlane As WorkPlane
Set oWkPlane = oWkPlanes.AddByPlaneAndOffset(selectedFace, 0, False)
'Create and Define Sketch to be placed on working plane
Dim oSketch As Inventor.PlanarSketch
Set oSketch = oPDef.Sketches.Add(oWkPlane)
Dim oTG As TransientGeometry
Set oTG = ThisApplication.TransientGeometry
Dim oCoord0 As Point2d
Set oCoord0 = oTG.CreatePoint2d(0, 0)
Dim oCoord1 As Point2d
Set oCoord1 = oTG.CreatePoint2d(1, 1)
Dim oLine As SketchLine
Set oLine = oSketch.SketchLines.AddByTwoPoints(oCoord0, oCoord1)
Dim oWkPt As WorkPoint
Set oWkPt = oPDef.WorkPoints.AddFixed(oCoord1, False)
End Sub
Solved! Go to Solution.