Adding A Dimension from a point or Sketch entity to an edge of a face

Adding A Dimension from a point or Sketch entity to an edge of a face

cencinaNB2ET
Advocate Advocate
1,662 Views
2 Replies
Message 1 of 3

Adding A Dimension from a point or Sketch entity to an edge of a face

cencinaNB2ET
Advocate
Advocate

I have gone through the API help page on Inventor 2018 and i cant find any examples there nor in the forum.

 

Basically You select a face, you place a point and you can make that point a hole, that is fine.

But that centre-point is not constrained with dimensions towards the edges of that particular face.

 

how can I just add a dimension by code, either by ilogic or VBA?

 

The API help page talks about geometric constraints but a not adding a dimension.

 

Capture 3.PNG

 

You can see the point is unconstrained ( green)

I want to add to dimensions towards the referenced edges of that face.

 

pretty simple right?

 

 

Please see that attached part with Rule 1 in ilogic.

 

 

 

 

 

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

YuhanZhang
Autodesk
Autodesk
Accepted solution

Below is a VBA sample for your specific data to create the dimensions for the hole center, open the data, and run below code to see the result:

 

Sub CreateOffsetDimConstraintSample()
    Dim oDoc As PartDocument
    Set oDoc = ThisApplication.ActiveDocument
    
    Dim oSk As PlanarSketch
    Set oSk = oDoc.ComponentDefinition.Sketches("My New Sketch")
    
    Dim oFace As Face
    Set oFace = oDoc.ComponentDefinition.Features.ExtrudeFeatures(1).SideFaces(1)
    
    Dim oHoleCenter As SketchPoint
    Set oHoleCenter = oSk.SketchPoints(1)
    oDoc.SelectSet.Select oHoleCenter
    
    oSk.Edit
    oSk.AddByProjectingEntity oFace.Edges(2)
    oSk.AddByProjectingEntity oFace.Edges(5)
    
    Call oSk.DimensionConstraints.AddOffset(oSk.SketchLines(1), oHoleCenter, ThisApplication.TransientGeometry.CreatePoint2d(2, 2), False)
    Call oSk.DimensionConstraints.AddOffset(oSk.SketchLines(2), oHoleCenter, ThisApplication.TransientGeometry.CreatePoint2d(-2, 0), False)
    
    oSk.ExitEdit
End Sub

 

Please let me if it works for you.



If this solves the problem please click ACCEPT SOLUTION so other people can find it easily.



Rocky Zhang
Inventor API PD
Manufacturing Solutions
Autodesk, Inc.

Message 3 of 3

cencinaNB2ET
Advocate
Advocate

That is great!

Thank you.

 

Now I need to identify the consumed by parameter ( This new sketch name ) in order to change the access the dimension since i dont know that dimension name being added.

 

So i can access this dimension and give it some value as soon as its created.

 

Thanks again.

0 Likes