Showing results for 
Search instead for 
Did you mean: 

Relations2D to existing geometry


Part environment, I'm drawing a 2D circle and want to add tangent relationships to existing model geometry.


I know what edges I want to use but they are Line type and not Line2D types and the AddTangent method returns me an error.


I'm sure all the edges and the circle are on the same plane.


How do I achieve that ?






Re: Relations2D to existing geometry


To be more specific I have a part that contains exagonal cutout; I want to create reference geometry to use for assembly relationship.


The geometry to create are cylinders tangents to the exagonal cutouts.


In attachment an example part.


And here the actual code:


Dim objApp As SolidEdgeFramework.Application
Dim objPsm As SolidEdgePart.SheetMetalDocument

Dim objLoop As SolidEdgeGeometry.Loop
Dim objEdge As SolidEdgeGeometry.Edge

Dim L As Double
Dim Lv As Double

Dim valido As Boolean

Dim objCircs As SolidEdgeFrameworkSupport.Circles2d
Dim objRelns As SolidEdgeFrameworkSupport.Relations2d

Sub Main()
Set objApp = GetObject(, "SolidEdge.Application")
If objApp.ActiveDocumentType = igSheetMetalDocument Then
Set objPsm = objApp.ActiveDocument
If objPsm.Models(1).BodyType = igSheetMetalType Then
For Each objLoop In objPsm.Models(1).Body.Loops
If objLoop.Edges.Count = 6 Then
valido = True
For Each objEdge In objLoop.Edges
If objEdge.Geometry.Type <> 167551109 Then valido = False 'igLine constant
Next objEdge
If valido Then
Lv = 0
For Each objEdge In objLoop.Edges
Call objEdge.GetLengthAtParam(-1, 1, L)
L = Round(L, 6)
If Lv = 0 Then Lv = L
If Lv <> L Then valido = False
Next objEdge
If valido Then
Debug.Print "Loop numero = " + CStr(objLoop.Id)
Debug.Print "Lunghezza = " + CStr(L)

'drawing a 2D circle
Set objCircs = objPsm.ProfileSets.Add.Profiles.Add(pRefPlaneDisp:=objPsm.RefPlanes(1)).Circles2d
Call objCircs.AddBy3Points(X1:=0, Y1:=0, X2:=0.01, Y2:=0.02, x3:=0.02, y3:=0.01)

Set objRelns = objCircs.Parent.Relations2d
Call objRelns.AddTangent(objLoop.Edges(1).Geometry, objCircs(1)) 'these drops an error, doesn't work
Call objRelns.AddTangent(objLoop.Edges(2).Geometry, objCircs(1)) 'these drops an error, doesn't work
Call objRelns.AddTangent(objLoop.Edges(3).Geometry, objCircs(1)) 'these drops an error, doesn't work
End If
End If
End If
Next objLoop
End If
End If
End Sub


Re: Relations2D to existing geometry


I have found myself the solution.

To use an edge for relationship you need to project it on the profile plane by using the ProjectEdge method of the profile.


I have changed the code like this:


 Call objRelns.AddPointOn(objProfile.ProjectEdge(objLoop.Edges(1)), 0, objCircs(1))
Call objRelns.AddPointOn(objProfile.ProjectEdge(objLoop.Edges(2)), 0, objCircs(1))
Call objRelns.AddPointOn(objProfile.ProjectEdge(objLoop.Edges(3)), 0, objCircs(1))