Question on GeometricConstraints.Addtangent

Question on GeometricConstraints.Addtangent

Anonymous
Not applicable
444 Views
4 Replies
Message 1 of 5

Question on GeometricConstraints.Addtangent

Anonymous
Not applicable

Hi, I would like to create a tangential line to a circle from one sketch point with API

 

We know that from one point it is possible to draw two tangential lines to a circle. However, in API, the GeometricConstraints.AddTangent does not provide parameter for programmer to specify which option to choose.

 

So my question is: how can I use API to create the tangential line as I want?

 

Thanks.

0 Likes
445 Views
4 Replies
Replies (4)
Message 2 of 5

philippe.leefsma
Alumni
Alumni

Hi,

 

Sorry, I don't get what your issue is. The "GeometricConstraints.AddTangent" method takes two already existing sketch entities, in that case it would be a SktechLine and a SketchCircle, it also takes as input a "ProximityPoint" parameter that should allow you to apply the tangency at the desired position. Make sure you take a look at the description of that method in the API Help Files.

 

Regards,

Philippe. 



Philippe Leefsma
Developer Technical Services
Autodesk Developer Network

0 Likes
Message 3 of 5

Anonymous
Not applicable

Thanks Philippe, I did think the Proximity parameter might be what I need. Will try it.

0 Likes
Message 4 of 5

Anonymous
Not applicable

Hi Philipe,

 

I tried the following code, however, the AddTangent methods does not work in any of the last four calls.

 

Could you (or sb. else) help me out?

 

Thanks,

 

Don

 

 

'----------- Code start ----------------

Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
Dim oPtDoc As PartDocument = _invApp.ActiveDocument
Dim oTG As TransientGeometry = _invApp.TransientGeometry
Dim oCompDef As PartComponentDefinition = oPtDoc.ComponentDefinition
Dim oSketch As PlanarSketch = oCompDef.Sketches.Add(oCompDef.WorkPlanes(1))


Dim oSkPoints(6) As SketchPoint
Dim x(6) As Double
Dim y(6) As Double

Dim oLines(3) As SketchLine
Dim oCircle(3) As SketchCircle

x(0) = 0
y(0) = 0
oSkPoints(0) = oSketch.SketchPoints.Add(oTG.CreatePoint2d(x(0), y(0)))

oCircle(0) = oSketch.SketchCircles.AddByCenterRadius(oSkPoints(0), 60)

 

x(1) = 100
y(1) = 0
oSkPoints(1) = oSketch.SketchPoints.Add(oTG.CreatePoint2d(x(1), y(1)))

 

x(2) = 0
y(2) = 80
oSkPoints(2) = oSketch.SketchPoints.Add(oTG.CreatePoint2d(x(2), y(2)))

 

x(3) = 0
y(3) = -80
oSkPoints(3) = oSketch.SketchPoints.Add(oTG.CreatePoint2d(x(3), y(3)))

 

oLines(0) = oSketch.SketchLines.AddByTwoPoints(oSkPoints(1), oSkPoints(0))
oLines(1) = oSketch.SketchLines.AddByTwoPoints(oSkPoints(1), oSkPoints(2))

oLines(2) = oSketch.SketchLines.AddByTwoPoints(oSkPoints(1), oSkPoints(3))

 

'try to create Tangent constraint between oLines(0) and oCircle(0) and make the tangential point close to oSkPoint(2)

Call oSketch.GeometricConstraints.AddTangent(oLines(0), oCircle(0), oSkPoints(2)) 

 

'try to create Tangent constraint between oLines(0) and oCircle(0) and make the tangential point close to oSkPoint(3)

Call oSketch.GeometricConstraints.AddTangent(oLines(0), oCircle(0), oSkPoints(3))

 

'try to create Tangent constraint between oLines(1) and oCircle(0) and make the tangential point close to oSkPoint(2)

Call oSketch.GeometricConstraints.AddTangent(oLines(1), oCircle(0), oSkPoints(2))

 

'try to create Tangent constraint between oLines(1) and oCircle(0) and make the tangential point close to oSkPoint(3)

Call oSketch.GeometricConstraints.AddTangent(oLines(1), oCircle(0), oSkPoints(3))

 

End Sub

0 Likes
Message 5 of 5

philippe.leefsma
Alumni
Alumni

I'm checking the comments from API Help files:

 

ProximityPoint
Optional input Point object that specifies where the tangency should be applied in the case where the input entities share two sketch points. 

 

As far as I see in your code, your lines and circle do not share two comon sktech points, so this argument does not apply. You should create the tangent constraint using the first 2 arguments, then modify your sketch entities properties so they reside at the right position.

 

You may also try creating the entities directly at the right position by your own geometric computation, then add the constraint, which should result in the entities not being positionally modified, but simply constrained.

 

Regards,

Philippe.

 



Philippe Leefsma
Developer Technical Services
Autodesk Developer Network

0 Likes