×
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

Need to know how to select a Line with VBA Macro

Need to know how to select a Line with VBA Macro

Need to know how to select a Line with VBA Macro

(OP)
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

RE: Need to know how to select a Line with VBA Macro

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

RE: Need to know how to select a Line with VBA Macro

(OP)
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.

RE: Need to know how to select a Line with VBA Macro

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

https://picasaweb.google.com/102257836106335725208 - Romania
https://picasaweb.google.com/103462806772634246699... - EU

RE: Need to know how to select a Line with VBA Macro

(OP)
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

RE: Need to know how to select a Line with VBA Macro

(OP)
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.

RE: Need to know how to select a Line with VBA Macro

(OP)
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.

RE: Need to know how to select a Line with VBA Macro

(OP)
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.

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