Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Catia Multiple Selection

Status
Not open for further replies.

NaWin55

Mechanical
Mar 21, 2020
97
IN
Hello
Hope you all doing well
i want to create a macro using VBSCRIPT to select multiple points
i can do it with CATSCRIPT but how di i do it with VB SCRIPT
i want to select manually i dont want macro to select anything
i searched here but i didnt find exact answer
Thannks
 
Replies continue below

Recommended for you

in CATscript you can use Selection.SelectElement2,3 to make user interaction(user selection) but in VBscript Selection.SelectElement2,3 doesnt work
I tried it
 
I can assure you it works as CATSCRIPT and VBSCRIPT are the same.

What error do you get?
 
Here is the script (VB Script)and Error

Option Explicit
Sub CATMain()

Dim oDoc As Document
Set oDoc = CATIA.ActiveDocument

Dim partDoc As PartDocument
Set partDoc = CATIA.ActiveDocument

Dim part As part
Set part = CATIA.ActiveDocument.part

Dim bodys As bodies
Set bodys = part.bodies

Dim oBody As body
Set oBody = bodys.Item(1)

Dim osel As Selection
Set osel = CATIA.ActiveDocument.Selection
osel.Clear

Dim inputObjectType()
ReDim inputObjectType(1): inputObjectType(0) = "Point"

Status = osel.SelectElement2(inputObjectType, "Select Point", True)

If (Status = "Cancel") Then
MsgBox "Selection Cancelled by user"

Else
oBody.Name = "Name"

End If




End Sub

Error
Error_sseewz.jpg


SelectElement2 wont work in vbscript i guess or i dont know how to use it properly
 
This is VBA, not VBscript.

Moreover, have you tried searching the forum for this error? It has been answered millions of times.
 
My bad i confused VBA with VBscript
i searched in the forum but i havent found anything do you have any link to thread related to selectElement2,3 or this type of issues, please give me a link
Thanks
 
Ok
I tried writing macro after reading script from this link

Here is MyMacro

Option Explicit
Sub CATMain()

Dim oDoc As Document
Set oDoc = CATIA.ActiveDocument

Dim partDoc As PartDocument
Set partDoc = CATIA.ActiveDocument

Dim part As part
Set part = CATIA.ActiveDocument.part

Dim bodys As bodies
Set bodys = part.bodies

Dim oBody As body
Set oBody = bodys.Item(1)

Dim osel As Selection
Dim osel2 As Object

Set osel = CATIA.ActiveDocument.Selection
Set osel2 = osel

osel.Clear

Dim varFilter(1) As Variant
varFilter(0) = "Point"
varFilter(1) = "Body"

Dim Status As String
Status = osel2.SelectElement2(varFilter, "Select a Point", False)

If (Status = "Cancel") Then
MsgBox "Selection Cancelled by user"

Else
MsgBox osel.Item(1).Value.name

End If

End Sub

its working fine when i run macro i select a point and it shows me name
But When i remove varFilter(1) = "Body" line it gives me this error
SelError_htlp7v.jpg


i am clearly not understanding the concept of FILTER AND INPUTOBJECTTYPE Concepts can u please Explain
Thanks
 
you are dimming varfilter to containg two items, varfilter(0) and varfilter(1) (that is what dim varfilter(1) implies, two slots)
so, for only one definition, you need to dim varfilter to varfilter(0),
if you have two definitions, dim varfilter(1)


regards,
LWolf
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top