×
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

Selected Hole Center

Selected Hole Center

Selected Hole Center

(OP)
Hi!
I developed a macro that select a hole! then make a point center of that hole!!

CODE -->

Dim productDocument1 As Document
Set productDocument1 = CATIA.ActiveDocument

Dim product1 As Product
Set product1 = productDocument1.Product

Dim selection1 
Set selection1 = productDocument1.Selection

Dim InputObjectType(0), Status1
InputObjectType(0)="Hole"

Status1=selection1.SelectElement2(InputObjectType,"Select un trou",false)
If Status1 = "Cancel" Then selection1.Clear: Exit Sub

Set oHole = selection1.Item(1).Value

Dim partDocument1 As Document
Set partDocument1 = documents1.Item("part1.catpart")

Dim part1 As Part
Set part1 = partDocument1.Part

Dim hybridShapeFactory1 As Factory
Set hybridShapeFactory1 = part1.HybridShapeFactory

Dim bodies1 As Bodies
Set bodies1 = part1.Bodies

Dim body1 As Body
Set body1 = bodies1.Item("Corps principal")

Dim sketches1 As Sketches
Set sketches1 = body1.Sketches

Dim shapes1 As Shapes
Set shapes1 = body1.Shapes

Dim hole1 As Shape
Set hole1 =shapes1.Item(nom_trou)

Dim sketch1 As Sketch
Set sketch1 = hole1.Sketch

Dim reference_piece As Reference
Set reference_piece1= part1.CreateReferenceFromObject(oHole)
Set reference_piece2= part1.CreateReferenceFromObject(sketh2) 
'Set reference1 = Selection1.Item(1).value

Dim hybridShapeFactory1 As Factory
Set hybridShapeFactory1 = part1.HybridShapeFactory

Dim hybridShapePointCenter1 As HybridShapePointCenter
Set hybridShapePointCenter1 = hybridShapeFactory1.AddNewPointCenter(reference_piece 1 ou 2??!! )

hybridBody1.AppendHybridShape hybridShapePointCenter1

part1.InWorkObject = hybridShapePointCenter1

part1.Update    th problem with update!! 

reference_piece1 or reference_piece2 in the 2 cases I have a problem with update! :Hole.1 the element has no associated geometry must recreate the geometry!
any suggestion please!!!!!!!

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