Obtain Absolute (x,y,z) Coordinates of point2d object

Obtain Absolute (x,y,z) Coordinates of point2d object

Anonymous
Not applicable
866 Views
2 Replies
Message 1 of 3

Obtain Absolute (x,y,z) Coordinates of point2d object

Anonymous
Not applicable

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

 

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

JelteDeJong
Mentor
Mentor
Accepted solution

if you dont mind creating a SketchPoint you can use the following:

Dim sketchPoint As SketchPoint
set sketchPoint = sketch.SketchPoints.Add(oCoord0)

Dim pointInModelSpace As Point
set pointInModelSpace = sketchPoint.Geometry3d

the pointInModelSpace contains the x,y,z values of the point2D 

Jelte de Jong
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.

EESignature


Blog: hjalte.nl - github.com

0 Likes
Message 3 of 3

Anonymous
Not applicable

yes this is perfect!

Thanks!

0 Likes