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!

CATIA MACRO HELP NEEDED

Status
Not open for further replies.

UGMENTALCASE

Aerospace
Oct 10, 2011
123
GB
Good Afternoon,

Ok so I'm after some help please. I have a catpart which is quite large (in file size approx 50mb) i have a load of holes in it, which I've put the wrong length of thread in, so I need to make them longer. I've recorded a macro, trimmed it down and then edited it. I have very little experience with macros, and to be honest probably dropped lucky following this one through. Basically there are holes number 100 - 258 (or something like that) so i've edited the macro to selct the hole number 100 change it then update it, select hole 101 change it update it, select hole 102 change it update it and so on. I'm aware you can 'loop' the commands, so how would i loop the command and add 1 to the hole number each time?

I appreciate the attached has a couple of holes missing, but fot the purpose of this we'll assume they run up in 1's. Someone into macro's please don't laugh at what i've done, it works and it's doing it for me now :) just need it quicker :)

Thanks in adavnce
 
 http://files.engineering.com/getfile.aspx?folder=ac24f755-4738-4e6e-aac2-219ce826f750&file=Macro3.catvbs
Replies continue below

Recommended for you

Hi

Please read the comment inside code, maybe you can do some improvements. Also, is useful to upload a CATPart sample if possible, something simple in order to test...

Code:
Language="VBSCRIPT"

Sub CATMain()

Set partDocument1 = CATIA.ActiveDocument
Set part1 = partDocument1.Part
Set bodies1 = part1.Bodies
Set body1 = bodies1.Item("PartBody")
Set shapes1 = body1.Shapes

Set selection1 = partDocument1.Selection
selection1.Search "Type=Hole,all"  ''you can change search criteria here according to your needs - maybe a specific diameter ot hole type

    For i=1 To selection1.Count

    '~ Set hole1 = shapes1.Item("Hole.153") ''replaced by next line which will do the loop
    Set hole1 = selection1.Item(i).Value

    hole1.ThreadingMode = catThreadedHoleThreading
    hole1.ThreadSide = catRightThreadSide
    Set length1 = hole1.ThreadDepth
    length1.Value = 7.000000
    Next

part1.Update 

End Sub



Regards
Fernando

- Romania
- EU
 
OH your are wonderfull!!!!!! I've just done a sample plate, slapped a load of holes all over it. Edited one hole with a macro recording so it can give me the code. Copied and pasted bits, and bam it's done!!!

Thank you so much. I'll have a play with this now and make up some edits for use. We do sometimes get this type of job where holes get modified so this will be a real time saver!

Thanks again
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top