Hello,
I am trying to get all the edges and the faces corresponding to all the solid bodies present in the CATIA 3D part using VB.NET 2010
Can someone help me with a sample code or API's which I can use to get this data.
Thanks,
Amitabh Mukherjee
Hello,
I am trying to get all the edges and the faces corresponding to all the solid bodies present in the CATIA 3D part using VB.NET 2010
Can someone help me with a sample code or API's which I can use to get this data.
Thanks,
Amitabh Mukherjee
Hi
I'm sure the bellow example code in CATScript you can implement in VS....
Sub CATMain()
Dim objSel As Selection
Set objSel = CATIA.ActiveDocument.Selection
objSel.Search ("Type=Edge,all")
objcount = objSel.Count
MsgBox objcount
End Sub
Best regards
Fernando
When I looked at this recently I noticed it also select edges of sketches inside the solid.
I change the color of the solid edges and add color to the selection= did not work.
I also put the sketches on another layer and restrict layer in selection = did not work
Playing with visible parameter... no more luck.
V6 2013x gives same results as R20.
solution might be to copy past solid as result (no more sketches) and select edges from that isolated body only, or look in the BREP name of the edge and remove the one from the sketches...
In Reply to Eric Neuville:
When I looked at this recently I noticed it also select edges of sketches inside the solid.
You are right.
Try this
Sub CATMain()
CATIA.ActiveDocument.Selection.Clear
Set osel = CATIA.ActiveDocument.Selection
osel.Search "Type=Topology.Face,all"
Dim oFoundEdges
Set oFoundEdges = CreateObject("Scripting.Dictionary")
For j = 1 To osel.Count
sEdgeName = osel.Item(j).Value.name
Dim aEdgeName
aEdgeName = Split(sEdgeName, "face")
sEdgeName = "face" & aEdgeName(UBound(aEdgeName))
If InStr(sEdgeName, sFaceName1) and InStr(sEdgeName, sFaceName2)
Then
Dim Edge
Set Edge = osel.Item(j).Value
oFoundEdges.Add j, Edge
iFoundEdges = iFoundEdges + 1
End If
Next
osel.Clear
If Not iFoundEdges = 0 Then
For j = 1 To oFoundEdges.Count
osel.Add oFoundEdges.Item(j)
Next
MsgBox oFoundEdges.Count
Else
MsgBox "No edges found"
End If
End Sub
Best regards
Fernando
I used the following code to get all the edge names and the face names in a given 3D Part. Thank you all for the pointer.
Using the .Value property , I can get hold of the 2D face and the 1D edge objects.Now I need to know if there is a way I can determine the start point and end point in 3D coordinates for each of these edges and also get the edge and face types.
Sub CATMain()
' get selected edge (using Edge class is crucial)Dim CATIA As INFITF.ApplicationCATIA = System.Runtime.InteropServices.Marshal.GetActiveObject("CATIA.Application") 'CATIA = GetObject(, "CATIA.Application")If CATIA Is Nothing Then CATIA = CreateObject("CATIA.Application")
CATIA.ActiveDocument.Selection.Clear()Dim osel As Selection
osel = CATIA.ActiveDocument.Selectionosel.Search("Type=Topology.Face,all")
Dim sFaceName As String = ""Dim sEdgeName As String = ""Dim oFace As Face = NothingDim oEdge As Edge = Nothing
For j = 1 To osel.CountsFaceName = osel.Item(j).Value.NameoFace = DirectCast(osel.Item(j).Value, Face)Nextosel.Clear()
osel = CATIA.ActiveDocument.Selectionosel.Search("Type=Topology.Edge,all")
For j = 1 To osel.CountsEdgeName = osel.Item(j).Value.NameoEdge = DirectCast(osel.Item(j).Value, Edge)Nextosel.Clear()
MsgBox("Completed")
End Sub
Thanks,
Amitabh