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)
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?
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
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
I've been thru some (stupid) stuff myself during my learning phase (which is not finished yet)
indocti discant et ament meminisse periti
RE: Problem with selection under macro
Regards
Fernando
https://picasaweb.google.com/102257836106335725208 - Romania
https://picasaweb.google.com/103462806772634246699... - EU
RE: Problem with selection under macro
Tiago Figueiredo
Tooling Engineer
Youtube channel:
https://www.youtube.com/channel/UC1qdlBeJJEgMgpPLV...