Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations KootK on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Holes coordinates in a plate

Status
Not open for further replies.

Lea75

Mechanical
Feb 24, 2009
51
I have a rectangular plate (Catpart) with different holes in diameter and type.

I'd like to write a catscript that can extract the coordinates of all of them to a txt file sorted by Ø, x and y.

Does anybody have any idea of how can I get this? Any example or advice?

Thanks in advance
 
Replies continue below

Recommended for you

Hi,

Did you solve this problem?

Regards
Fernando
 
No, no yet... :(
Do you have any suggestion?
 
I would suggest you to create some points first, something like in the attachment...then you can collect the coordinates with this (thanks to Eric).

Eric post this catvba also in other forums if I remember correctly and I tested another version of this catvba in r18 and worked fine (I've modified only the path - if Eric agree and somebody wants I can post the catvba also here).



Regards
Fernando
 
no problemo... go ahead...sharing is good.

Do you know if your plate does have "hole' features or if those holes cn be defined by pocket, groove, BO, split (with surface)...???

May be you can select 1 by 1 all edges of the solid then create a cicle center point. If it works, you have (X,Y,Z) then get Ø . if it fails go next edge.

Eric N.
indocti discant et ament meminisse periti
 
Thank you for your answers.
I will explain my case...
I have a simple rectangular plate (Catpart made with Part Design module) with lot of holes.
All holes were created with the command HOLE.
The Ø of them can be different, also their type... some threated, others counterbordered, etc.
The problem is that it is very slow to create the center point one by one and then extract the coordinates of each point, except if this operation could be managed automatically.
 
The main use of the macro that I want to make is to create a drilling program for a CNC drilling machine.
The catvba and catscript that you sent are very interesting. Thank you very much.
I'll see what can I do with them, but I don't see clear how can I extract the Ø and hole type.
I'll continue trying.
Thanks again :)
 
I think you might have a business case for a CAA application. I was part on something like this years ago.

You should consider the money you will save with a script (CAA or VB/VBA) and what it costs.

The time you spend trying to get info and script that will never fit 100% of what you need might be precious, don't waste it.

Eric N.
indocti discant et ament meminisse periti
 
Hi,

I was looking for something else and an idea came to me..see the attachment...

For the hole type you have:
0 - simple
1 - tapered
2 - counterbored
3 - countersunk
4 - counterdrilled

You can improve the code, there is also in documentation (v5automation.chm file) a procedure to GetOrigin of the hole...if you can improve the code I would like to see how you handled...

Regarding your question about freezing CATIA when you use my CATScript for extrude text which I posted in COE forum...I have no idea...but I know if the text is long or fonts are complicated it will take long time to run...



Regards
Fernando
 
 http://files.engineering.com/getfile.aspx?folder=40d78889-1648-4afc-a1b9-4f2ad3b92f3d&file=Hole_name_dia_type.zip
I forgot to mention that for the mold workbench there is a macro developed by DS in their documentation (hope I remember well), used for plates not CATParts done in Part Design...

Regards
Fernando
 
Thank you Ferdo, it seems that we are in the good way.
I'll try to handle the code, but I am a beginner in scripting so it will takes time to me.
If I have any doubt, I'll ask you again.
Kind regards
 
Can't remember where I got it, just done slight modifications..

Sub catmain()

'get the selection object
Dim sel
Set sel = CATIA.ActiveDocument.Selection

'set up a selection filter
Dim fil(0)
fil(0) = "Hole"

'perform the selection
Dim ans
ans = sel.SelectElement2(fil, "Select a hole", False)

'check that selection was not cancelled
If ans <> "Normal" Then Exit Sub

'get the hole
Dim theHole As Hole
Set theHole = sel.Item(1).Value

Msgbox "Hole Name = " & theHole.Name

'need a variant object in order to use method returning array
Dim vHole As Variant
Set vHole = theHole

'get the origin of the hole using the variant object
Dim origin(2)
vHole.GetOrigin (origin)

Msgbox "Origin = " & origin(0) & ", " & origin(1) & ", " & origin(2)

End Sub

Regards
Fernando
 
Hi Ferdo, thank you very much.
This is really interesting.
At the moment, I solved the problem by getting a Catdrawing with the holes coordinates, and then export each one to a txt file.
With your last suggestion, you opened me a door to a better solution, saving time on taking a Catdrawing.
I will play with your code and see if I finally make the application that I need.
Thank you very much again. Kind regards.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor