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
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
When I change the FilterType of the array to allow "Line2D" then it works on my end. See here.
CODE --> vba
Regards,
Drew Mumaw
http://www.drewmumaw.com/
http://www.textsketcher.com/
RE: Catia Macro: SelectElement2 Return wrong Item Type
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
@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
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
RE: Catia Macro: SelectElement2 Return wrong Item Type
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
This also returns the same thing i.e. "DrawingView"
RE: Catia Macro: SelectElement2 Return wrong Item Type
@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
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
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
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.