Count point in Sketch Macro
Count point in Sketch Macro
(OP)
Hi, can anyone help me with the macro who will Count Points in CATIA.
I founded this macro who Count sketch based Features, but i dont know how to Count Points, any help
thx
Sub CATMain()
On Error Resume Next
Dim partDoc1 As PartDocument
Set partDoc1 = CATIA.ActiveDocument
If Err.Number <> 0 Then
MsgBox “Active document is not a part document!“”
End
End If
Dim body1 As Body
Set body1 = partDoc1.Part.Bodies.Item(1)
Dim shapes1 As Shapes
Set shapes1 = body1.Shapes
shapecount = shapes1.count
Dim shape1 As Shape
Dim sketchShape As SketchBasedShape
Dim count1 As Integer
count1 = 0
For i = 1 To shapecount
Set sketchShape = shapes1.Item(i)
If Err.Number = 0 Then
count1 = count1 + 1
End If
Err.Clear
Next
MsgBox “Number of sketch based shapes is: ” & count1
End Sub
I founded this macro who Count sketch based Features, but i dont know how to Count Points, any help
thx
Sub CATMain()
On Error Resume Next
Dim partDoc1 As PartDocument
Set partDoc1 = CATIA.ActiveDocument
If Err.Number <> 0 Then
MsgBox “Active document is not a part document!“”
End
End If
Dim body1 As Body
Set body1 = partDoc1.Part.Bodies.Item(1)
Dim shapes1 As Shapes
Set shapes1 = body1.Shapes
shapecount = shapes1.count
Dim shape1 As Shape
Dim sketchShape As SketchBasedShape
Dim count1 As Integer
count1 = 0
For i = 1 To shapecount
Set sketchShape = shapes1.Item(i)
If Err.Number = 0 Then
count1 = count1 + 1
End If
Err.Clear
Next
MsgBox “Number of sketch based shapes is: ” & count1
End Sub





RE: Count point in Sketch Macro
RE: Count point in Sketch Macro
Sub CATMain()
Set Document = CATIA.ActiveDocument
Dim oPart As Part
Set oPart = Document.Part
Dim oBody As Body
Set oBody = oPart.Bodies.Item("PartBody")
Dim InputObject(0)
Dim oStatus
InputObject(0) = "Sketch"
Set oSel = CATIA.ActiveDocument.Selection
oStatus = oSel.SelectElement2(InputObject, "Select the Sketch", True)
Dim oSketch As Sketch
Set oSketch =oBody.Sketches.Item("osel.item(1).value.name")
Dim geometricElements1 As GeometricElements
Set geometricElements1 = oSketch.GeometricElements
Dim count1 As Integer
count1 = -1
For i = 1 To geometricElements1.Count
If Err.Number = 0 Then
count1 = count1 +1
End If
Next
MsgBox "the number of point is: " & count1
End Sub
RE: Count point in Sketch Macro
Set oSketch = oBody.Sketches.Item(osel.item(1).value.name)
______
Alex ,
RE: Count point in Sketch Macro
RE: Count point in Sketch Macro
Set mysketch = Selection.Item(1).Value
Dim oSketch As Sketch
Set oSketch =oBody.Sketches.Item(mysketch.name)
______
Alex ,
RE: Count point in Sketch Macro
i use this snippet code... you should try..
Set mysketch = oSel.Item(1).Value
Dim oSketch As Sketch
Set oSketch =oBody.Sketches.Item(mysketch.name)
______
Alex ,
RE: Count point in Sketch Macro
RE: Count point in Sketch Macro
oSketch = oSel.Item(1).Value should resolve your issue.
--Doug
RE: Count point in Sketch Macro
Set oSketch = oSel.Item(1).Value
RE: Count point in Sketch Macro