TiagoFigueiredo
Industrial
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?
Tiago Figueiredo
Tooling Engineer
Youtube channel:
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: