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!

Need to know how to select a Line with VBA Macro

Status
Not open for further replies.

majke

Computer
Jun 13, 2017
6
ES
Hello, I am trying to create a VBA macro which automatically create tracks in the DMU Fitting module.

For doing that, I need a shuttle, which represents the part I want to move and a line, which represents the track (path of the part in a dissasembly, for example). Then I select the "Generate Track" command in VBA and the shuttle which I wanna move, so CATIA opens a window in which I have to select the track.

The problem is that I can't select the line from the tree as you can see in the attached picture (it could have been done with the search command), I have to select it clicking directly with the mouse on the line, and I do not know if there is a function that allows me to do that in VBA.

If you need more information please, contact me, it's hard to explain [bigsmile]

Thank you in advance
 
 http://files.engineering.com/getfile.aspx?folder=673a78f9-f71b-4fcf-a17b-d44f4e6221e0&file=CATIAdoubt.png
Replies continue below

Recommended for you

it seems you need to select an edge, not a line. Change your code to allow line selection.

Eric N.
indocti discant et ament meminisse periti
 
Yess you are right, I need to select an edge. How can I change the code for selecting lines? I am sorry but I'm a bit lost here.
 
Hi

You have to use in your code something like below (that is code for forcing user to be able to select only Geometrical Sets, you need to change for what you want). Search also forum for examples.


Dim InputType(0), Status As String
InputType(0) = "HybridBodies"
Status = MySelection.SelectElement2(InputType, "Select a Geometrical Set", False)
If (Status = "Cancel") Then Exit Sub

Regards
Fernando

- Romania
- EU
 
Hi Ferdo,

First of all, thank you for your post.

I know what you mean, but my idea is that the macro could automatically select this edges, not the user. I mean, I know exactly which edge correspond to each shuttle, so it is better to do it in the macro.

Thank you again for you responses.

Hope that you can understand what I mean.

Regards
 
I tried but VBA only allows me to do that if the geometry can be selected from the tree. In that case it can't be selected from the tree, it must be selected clicking directly on the line in the 3D model.
 
I have noticed that I need to select edges, not lines, I did not know the difference, now I did.

I have tried with the function search and I can find all the edges of the model, but I do not know how to select the edge that I want. I am sure that it must exist a better way to do it, and I hope you can help me.

Thank you in advance.
 
I found the solution. I want to share it with you just in case another user have the same doubt.

First of all, I need to select the line which corresponds with the edge I want, then I search the edge of this line in my previous selection. Here is the code.

Dim objSel As Selection, oSel As Selection
Set objSel = CATIA.ActiveDocument.Selection
objSel.Search ("Name=Shuttle.1,all")
Set oSel = CATIA.ActiveDocument.Selection

oSel.Search ("Name=Line.1,all")
objSel.Search ("Topology.CGMEdge,sel")


Thank you very much for the replies to my post. Hope I can help someone else with this.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top