Continue to Site

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!

code for making LH parts..

Status
Not open for further replies.

appvid

Automotive
Nov 9, 2012
81
Hi guys, could some one give me clues for making LH side parts via VBA.

There may be one ore more solidbodies and geosets in a part. I want script that does symmetric for every body so that I have my LH side ready. (XZ plane is my reference for symmetry). Appriciate your help.

I am new to this forum and sorry if this topic was already discussed.

thanks heaps..

appvid
 
Replies continue below

Recommended for you

Hi Fernando, thanks for the link.
Yes I wanted whole part to be mirrored. I tried to record a macro using symmetry option in Product work bench but no luck.

some one helped me with code that mirrors all bodies. But I also need all features in all geometric sets mirrored too.. Is there any alternative...

Thanks

 
Here is grabout of code from your chm file. ( this code looks too high and i do not get a sigle line out of it :) )
Code:
Sub CATMain() 

Dim dblPosition(11) 

Set objSel = CATIA.ActiveDocument.Selection

objSel.Clear

objSel.SelectElement2 Array("Product"), "Select the product to symmetry...", False

Set objProd = objSel.Item2(1).Value 

objProd.Position.GetComponents dblPosition 

'Invert y coord of part origin y direction vector

dblPosition(10) = -dblPosition(10)

dblPosition(4) = -dblPosition(4)

objProd.Position.SetComponents dblPosition 

End Sub

this does mirror same part in the assembly. I think I have to go for " create CATpart from Product" to get my LH part in position.
 
I use the above macro with a few mods. Yes the above version is for products (everything I symmetry is a product based). You could modify the above macro to select parts only

objSel.SelectElement2 Array("Product"), "Select the product to symmetry...", False
to
objSel.SelectElement2 Array("Part"), "Select the part to symmetry...", False

To be tidy I would switch the

Set objProd
to
Set objPart

then
objProd.Position.GetComponents
to
objPart.Position.GetComponents
and
objProd.Position.SetComponents
to
objPart.Position.SetComponents

I have not tried this but it should work.

Regards,
Derek


Win XP64
R20SP7/21SP5, 3DVIA Composer 2013, ST R20
Dell T7400 16GB Ram
Quadro FX 4800 - 1.5GB
 
Hello Derek...For some reason that did not work...

First of all
Do i Have to work around to get complete mirror parts (LH parts). Initially i was assuming these steps

1) Open RH part
2) copy all geometry
3) Create new part
4) paste geometry (with out link)
5) Mirror all geometry in newly created part. ( I know how to mirror if there were only solid bodies in a part. I am not sure how do i go if there are geosets as well)


Coming to above script like i mentioned earlier selected part changes its position in assembly ONLY.

But it not real mirror part. I want a part that is mirror to my reference because we send parts to our supplier/customer.

Hope you got it..:)
Appvid
 
Hi,

First lets clarify some things.

How do want to create this LH parts? You have an opened assy and inside this you want to do - mirror or symetry?

You open separate the part and do LH parts (this should be in my opinion normal way of work)?

Why do you copy without link? If you changes something in RH part don’t you want also to be seen on LH?

Your part how is created? All GeoSets are under PartBody directly or?

I saw also that someone wants to have each body or GS to be done separately for LH but this is much more time consuming and not real necessary in my opinion (still, if your procedure to create the LH is saying that you have to do it like this, then is another problem).



Regards
Fernando

 
Hi Fernando
The LH and RH parts I'm creating are to send data out to my supplier/customer.

1) We work only on parts. I copy finished geometry to new file and create RH parts. Copy again to new file and mirror all featueres and make LH aprt .I do not have any opened assy. (pleas see attached image)

2) Yes we open separate file and make LH parts

3) We copy with out link because we do not want our suppler/customer to see our history,parametric modeling etc. If some thing gets changed in RH we create another set of RH and LH files

4) We do not have all created under part body. Usually we have few solids and few geo sets.
regards
 
 http://files.engineering.com/getfile.aspx?folder=535710e5-3302-4bc7-a60e-5e5bce0f002b&file=output_file_generation.jpg
Hi,

Now I see what you are trying to do (I saw also the answer in the German forum, a lot of users with big experience there and a lot of knowledge).

By coping w/o link you mean you are using Copy-Paste Special-As Result in order to have a dumb solid without history in a new "fake" RH part, then you are doing LH part from this new fake RH.

In this case it means you only copy the bodies (all of them), no GS, no other feature, there is no need for this and the result it will be an isolated dumb solid (still, for someone which want to recreate your original part with history it will not be so difficult, this is not the best way to protect your work and in fact I don't know if is existing a real way to protect something, there are so many ways for reverse engineering...).

Your macro should do several operations: copy all bodies from working file, open a new part, paste as result, save as fake RH name, copy this new dumb solid, open a new part, paste, symmetry (the German code is working good), then save as LH part.

Correct? If is so, take a look in that chm file done by me and you can take from there different codes in order to accomplish what you want. If you have problems, please post your code here to see if we can fix it.

Regards
Fernando

 
exactly, The german site is really good and scripting experts are very co-operative. It has got very good posts and very good modarators..Unfortunatly I do not speak German so I use transalator and try do understand the context.

Your chm file is beautiful. very usefull for beginners like me. A big thanks for creating and sharing it.

Coming to my script, we might also have geosets some times (we extract surface to indicate changes)
So I can manage to copy and paste with out link to new part (RH part). I do the same thing to LH part. Now I'm stuck with mirroring those.

I will put my script together and share it in this forum to make improvements.

Thansk for your reply..

Regards
Happy thanks giving

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor