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!

Help with changing hole properties

Status
Not open for further replies.

Alan Lowbands

Aerospace
May 17, 2017
274
GB
Hi guys,
Could anyone help.
I have to bring some parts up to a standard and I'm finding that there are lots of c/bored holes modeled differently.
I have tried to write a script that will change the properties of a selected hole to a set standard but I'm having no joy.
This is my fist go at a script for parts and I'm struggling :(

any help would be appreciated
thanks
Alan
 
Replies continue below

Recommended for you

well it would help if you can share your script and where the problem is...

Eric N.
indocti discant et ament meminisse periti
 
Hi guys,
I found this code but can't get it to work. It may be fine as a macro but it won't work as a script.
I have tried both methods to set the reference1 but neither seem to work.
I did have another that I botched together from bits of other scripts of but I must have overwritten it with this.
Any help, as always, is greatly appreciated

regards
Alan


Sub CATMain ()

'Dim reference1 'As Reference
'Set reference1 = selection1.Item(1).Value

'Dim reference1 'As Reference
'Set reference1 = part1.CreateReferenceFromObject(selection1.Item2(1).Value)

Dim hole1 'As Hole
Set hole1 = part1.CreateReferenceFromObject(reference1)

Dim oDiameter 'As Length
Set oDiameter = oAssemblyHole.Diameter
oDiameter.Value = 10.000000

oAssemblyHole.Type = catCounterboredHole
oAssemblyHole.AnchorMode = catExtremPointHoleAnchor

Dim oHeadDiameter 'As Length
Set oHeadDiameter = oAssemblyHole.HeadDiameter
oHeadDiameter.Value = 15.000000

Dim oHeadDepth 'As Length
Set oHeadDepth = oAssemblyHole.HeadDepth
oHeadDepth.Value = 5.000000

Dim oBottomLimit 'As Limit
Set oBottomLimit = oAssemblyHole.BottomLimit
oBottomLimit.LimitMode = catOffsetLimit

Dim oDepth 'As Length
Set oDepth = oBottomLimit.Dimension
oDepth.Value = 30.000000

oAssemblyHole.BottomType = catVHoleBottom

End Sub
 
Alan,

I suggest you create a part with a hole then you record a macro when you modify the dimension of the hole. that should give you a better start than the gibberish above (no offence)

Eric N.
indocti discant et ament meminisse periti
 
None taken lol
I did that to begin with but it pointed to the hole I recorded the macro on.
So when I ran the macro on another hole it just went to the first hole I recorded.
That's why I was looking at using a selection at the start of the script.
I will try recording it again and try and understand what's going on

cheers
Alan
 
Can someone please tell me how I select the hole I need to change.
Struggling with this one :(

regards
alan
 
check selection.selectelement2 method

Eric N.
indocti discant et ament meminisse periti
 
Does this command prompt you to select the hole ?
I was hoping to select the hole then run the script, would this still do that?
Heads starting to melt haha

regards
Alan
 
if selection is already made then jut get catia.activedocument.selection.item(1).value to get to the selected hole

Eric N.
indocti discant et ament meminisse periti
 
Hi

This is an quick example working in a CATPart. I believe you should also search the forum for other examples.

Code:
Language="VBSCRIPT"

Sub CATMain()

Set partDocument1 = CATIA.ActiveDocument
Set part1 = partDocument1.Part

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 = 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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top