×
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

Problem with selection under macro

Problem with selection under macro

Problem with selection under macro

(OP)
I'm having a problem with selection, under macro execution.

I have a product which contains another products and that products contains parts.

I need to select the parts under the 2nd product.



I have wrote the following macro (just the part of selection)

CODE -->

For i = 1 To Num_axis
                Dim comps As Integer
                Product2 = Product1.Products.Item(Number_parts + i - 1)
             
                comps = Product2.Products.Count

                For c = 1 To comps
                    selection1.Add(Product2.Products.Item(c))

                Next
            Next 

when the macro runs, looks good, but i can't see the selection on catia.Only we can see that there are something selected, because CATIA say that there are a few elements selected.

Like I can't see what is selected, and for debuging, I have resquested a message box, with the name of the selected elements. that message box returns me the part name of each part. It looked really good, So far so good.

But the next action is within each part find a body with a specific name, and copy and past it to another part. And here is the big problem. the body is not pasted in the same place of it's part location. Is pasted in the coordinates, where was drawn on original part. Ex: the part in assembly is located at coordinates 1000,1000,1000 and the body that i need to copy is drawn on 0,0,0, when i copy it in assembly it will appear on other part on location 0,0,0, not on 1000,1000,1000. it looks like i have opened the part with body, then open the other part and make a paste, not making the use of the in context location...

So trying to debug the code, I have removed the code of parts selection (the code that I have posted before), and stop the code at this point. After this I make the selection with mouse clicks, and resume the code. And like this it works really fine. So I assume that there is some problem with the selection of the parts with code.

Any idea?

Tiago Figueiredo
Tooling Engineer

Youtube channel:
https://www.youtube.com/channel/UC1qdlBeJJEgMgpPLV...

RE: Problem with selection under macro

(OP)
I love my UNknowledge of programming, I really don't know to control things like a real programmer.

Apparently the problem is solved. When I inserted the variable to product1 (which contains the product), I inserted a new variable.

product1 = selection1.Item(1).Value
My_Product = selection1.Item(1).Value

Exactly the same way that product1 is attributed it's value.

On the code of the previous post i switched from product1 to My_Product, and voilá it works!!!! Definitly I hate computors, because they are above my intelligence level. It must be a reason for this don't work properly, but i don't understand it.

Tiago Figueiredo
Tooling Engineer

Youtube channel:
https://www.youtube.com/channel/UC1qdlBeJJEgMgpPLV...

RE: Problem with selection under macro

you learn.. you're on the good track.

I've been thru some (stupid) stuff myself during my learning phase (which is not finished yet)

Eric N.
indocti discant et ament meminisse periti

RE: Problem with selection under macro

(OP)
I'm learning, without any doubt, but there are things completely stupid. I would like to see a real programmer to see my code. I think he would laugh so much, that he would stay out of words for about 2 days.
banghead

Tiago Figueiredo
Tooling Engineer

Youtube channel:
https://www.youtube.com/channel/UC1qdlBeJJEgMgpPLV...

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