×
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

Catia Macro: SelectElement2 Return wrong Item Type

Catia Macro: SelectElement2 Return wrong Item Type

Catia Macro: SelectElement2 Return wrong Item Type

(OP)
My Code is Below

Sub CATMain()

Dim MySelection 'As Selection
Dim MyDoc As Document
Dim MyPart As PartDocument
Dim MyDrawing As DrawingDocument
Dim MyProduct As ProductDocument

Set MyDrawing = CATIA.ActiveDocument
Set MySelection = MyDrawing.Selection

ReDim strArray(0)
strArray(0) = "DrawingView"
Dim Status As String

Status = MySelection.SelectElement2(strArray, "Select Drawing View", True)

If Status = "Cancel" Then
Exit Sub
End If

MsgBox MySelection.Item(1).Type

End Sub

I get Return Type as "DrawingView" even if i select Line2D object as shown in attached drawing sheet. But if I try this code without SelectElement2 (Selection Item Collection) I get return type as "Line2D"

Is it a Bug or a Feature ? Please suggest any workaround

RE: Catia Macro: SelectElement2 Return wrong Item Type

@jagandeep
When I change the FilterType of the array to allow "Line2D" then it works on my end. See here.

CODE --> vba

Sub CATMain()

Dim MySelection 'As Selection
Dim MyDoc As Document
Dim MyPart As PartDocument
Dim MyDrawing As DrawingDocument
Dim MyProduct As ProductDocument

Set MyDrawing = CATIA.ActiveDocument
Set MySelection = MyDrawing.Selection

ReDim strArray(1)
strArray(0) = "Line2D"
strArray(1) = "DrawingView"
Dim Status As String

Status = MySelection.SelectElement2(strArray, "Select Drawing View", True)

If Status = "Cancel" Then
Exit Sub
End If

MsgBox MySelection.Item(1).Type

End Sub 

Regards,
Drew Mumaw
http://www.drewmumaw.com/
http://www.textsketcher.com/

RE: Catia Macro: SelectElement2 Return wrong Item Type

Hi,
filter type is to filter the elements you want to select only.
If you are giving DrawingView as filtertype then you can select drawing view only from the selection.
Though you are selecting line2d, but it is giving back the view where this line resides because of filtertype.

Use filter type "AnyObject" to select any entity, you will get what you want.

Use TypeName(itemselected) for better handling of entities.

Regards,
Maddy

The willingness to share knowledge does not make one charitable; it makes one self-reliant to know more.
Modified - Courtesy of Robert Brault

RE: Catia Macro: SelectElement2 Return wrong Item Type

(OP)
@drewmumaw for that I have to Include each and every possible type as filter. Thats a pain :d

@Maddy If I select "AnyObject" as filter type then I get Return Type as any object. May be UseTypeName(itemselected) will solve this problem. Care to explain it how ??

RE: Catia Macro: SelectElement2 Return wrong Item Type

@jagandeep

Quote (jagandeep)

for that I have to Include each and every possible type as filter. Thats a pain :d

What are you trying to accomplish with the macro code you originally posted? What do you want to do after the user selects an object?

Regards,
Drew Mumaw
http://www.drewmumaw.com/
http://www.textsketcher.com/

RE: Catia Macro: SelectElement2 Return wrong Item Type

(OP)
Actually I want to select element and get its parent 3D model. If user select wrong element, the macro returns error. Although I have done this through On Error statement but there might be some built in catia way to find wrong selection!

RE: Catia Macro: SelectElement2 Return wrong Item Type

Use

MsgBox TypeName(oSelection.Item(1).Value)

Regards,
Maddy

The willingness to share knowledge does not make one charitable; it makes one self-reliant to know more.
Modified - Courtesy of Robert Brault

RE: Catia Macro: SelectElement2 Return wrong Item Type

(OP)

Quote (Maddy02)


Use
MsgBox TypeName(oSelection.Item(1).Value)

This also returns the same thing i.e. "DrawingView"

RE: Catia Macro: SelectElement2 Return wrong Item Type

Hi,

@jagandeep
When you are starting a thread do mention the purpose of what you are trying to do.
In your first post it doesn't mention anything about it.

And sorry for not having gone through with the post before my comment above

Quote:


Actually I want to select element and get its parent 3D model.

Unfortunately the method to get 3D Model from the geometric elements of any kind which represents the 3D model on paper, doesn't exist as Dassault has not given any exposure of this kind (up to my knowledge)

To get a parent 3d model of a generated drawing view use
Set objLinked3DModel = MyView.GenerativeBehavior.Document
and objLinked3DModel.Parent if required to open the 3D model

Quote:


If user select wrong element, the macro returns error
What do you mean by this? elaborate on this, if possible post a video of what you are doing.

Regards,
Maddy

The willingness to share knowledge does not make one charitable; it makes one self-reliant to know more.
Modified - Courtesy of Robert Brault

RE: Catia Macro: SelectElement2 Return wrong Item Type

(OP)
Buddy I think you it wrong, my bad
All I want is user select a drawing view and to switch to its parent 3d model. But in case user select anything other than drawing view, he gets an error message.

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