×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Help with changing hole properties

Help with changing hole properties

Help with changing hole properties

(OP)
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

RE: Help with changing hole properties

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

Eric N.
indocti discant et ament meminisse periti

RE: Help with changing hole properties

(OP)
I'll pop it on as soon as I get home :)
Cheers

RE: Help with changing hole properties

(OP)
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

RE: Help with changing hole properties

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

RE: Help with changing hole properties

(OP)
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

RE: Help with changing hole properties

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

regards
alan

RE: Help with changing hole properties

check selection.selectelement2 method

Eric N.
indocti discant et ament meminisse periti

RE: Help with changing hole properties

(OP)
Will do.
Thanks

RE: Help with changing hole properties

(OP)
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

RE: Help with changing hole properties

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

RE: Help with changing hole properties

(OP)
Thank you :)
I will get the hang of this eventually

Regards
Alan

RE: Help with changing hole properties

Hi

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

CODE --> CATScript

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

https://picasaweb.google.com/102257836106335725208 - Romania
https://picasaweb.google.com/103462806772634246699... - EU

RE: Help with changing hole properties

(OP)
Thanks guys,
I appreciate the help :)

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources