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
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
indocti discant et ament meminisse periti
RE: Help with changing hole properties
Regards
Fernando
https://picasaweb.google.com/102257836106335725208 - Romania
https://picasaweb.google.com/103462806772634246699... - EU
RE: Help with changing hole properties
Cheers
RE: Help with changing hole properties
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
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)
indocti discant et ament meminisse periti
RE: Help with changing hole properties
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
Struggling with this one :(
regards
alan
RE: Help with changing hole properties
indocti discant et ament meminisse periti
RE: Help with changing hole properties
Thanks
RE: Help with changing hole properties
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
indocti discant et ament meminisse periti
RE: Help with changing hole properties
I will get the hang of this eventually
Regards
Alan
RE: Help with changing hole properties
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 SubRegards
Fernando
https://picasaweb.google.com/102257836106335725208 - Romania
https://picasaweb.google.com/103462806772634246699... - EU
RE: Help with changing hole properties
I appreciate the help :)