×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Count point in Sketch Macro
2

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

RE: Count point in Sketch Macro

(OP)
I have now other problem, i want now to select Sketch and to count points in that selected sketch, the problem is in this line "Set oSketch =oBody.Sketches.Item("osel.item(1).value.name")" i dont know how to point on that selected sketc any help pls

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

try without the quotes ????

Set oSketch = oBody.Sketches.Item(osel.item(1).value.name)

______

Alex ,

RE: Count point in Sketch Macro

Try..


Set mysketch = Selection.Item(1).Value

Dim oSketch As Sketch
Set oSketch =oBody.Sketches.Item(mysketch.name)



______

Alex ,

RE: Count point in Sketch Macro

Im sorry i cant test because i dont have catia anymore..


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

(OP)
i tried, nothing :(

RE: Count point in Sketch Macro

The code snippet you are using assumes that the Sketch resides in the MainBody of the CATPart.
oSketch = oSel.Item(1).Value should resolve your issue.

--Doug

RE: Count point in Sketch Macro

2
Correction:

Set oSketch = oSel.Item(1).Value

RE: Count point in Sketch Macro

(OP)
yeah, it is resolved, thx dougsnell a lot, thx alex, i m happy now :)

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources