×
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

Use Step Product file in scripting references??

Use Step Product file in scripting references??

Use Step Product file in scripting references??

(OP)
I have a step product file containing two products 1 & 2.
product1 contains a hole. Now, i want to add a product 3 in which a hole is made concentric with this hole.
i write following program to excess cylinderical hole surface but it gives error.
Can anyone help that how to access this .

Sub

Dim products1 As Products
Set products1 = CATIA.ActiveDocument.Product.Products

'Add new part to product
Dim product2 As Product
Set product2 = products1.AddNewComponent("Part", "")

Dim PartNumber As String
PartNumber = product2.PartNumber & ".CATPart"

Dim partDocument1 As PartDocument
Set partDocument1 = CATIA.Documents.Item(PartNumber)

Dim part1 As part
Set part1 = partDocument1.part

Dim bodies1 As Bodies
Set bodies1 = part1.Bodies

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

part1.InWorkObject = body1

Dim hybridShapeFactory1 As Factory
Set hybridShapeFactory1 = part1.HybridShapeFactory

Dim Selection1 As selection
Set Selection1 = partDocument1.selection

Dim selection
Set selection = Selection1

Dim InputObjectType(0), Status

InputObjectType(0) = "CylindricalFace"
Status = selection.SelectElement2(InputObjectType, "Select a Cylindrical Face:", True)

Dim reference1 As Reference
Set reference1 = part1.CreateReferenceFromName(CylindricalFace.Name) 'showing Error

Dim hybridShapePlaneOffset1 As HybridShapePlaneOffset
Set hybridShapePlaneOffset1 = hybridShapeFactory1.AddNewAxisLine(reference1)

part1.Update

End Sub

I want to use this axis to concentric making of hole feature.
it gives error.Is there another better method.
I also want to use plane in product2 as a limit.
but same problem for creation of reference for plane.
Any suggestion would be great Help.

RE: Use Step Product file in scripting references??

CylindricalFace.Name this is your error.

The CylindricalFace object is not defined.

the face is in the selection.item(1) oject.

you can create the reference with the following:

CODE -->

Set reference1 = partDocument1.selection.item(1).reference 

also:

CODE -->

Dim selection
Set selection = Selection1 

is not nice as Selection is a catia object. you should not create object with name already used by CATIA.

and also:

you get the status in the following line

CODE -->

Status = selection.SelectElement2(InputObjectType, "Select a Cylindrical Face:", True) 

but you don't check the status before using the resulting selection... ?!? what if the user press "Cancel"?

Eric N.
indocti discant et ament meminisse periti

RE: Use Step Product file in scripting references??

(OP)
I have made all the corrections you suggested but still showing error,"method Addnewaxisline failed".
My new programchanged part is as:

Dim Selection1 As selection
Set Selection1 = partDocument1.selection

Dim selection2
Set selection2 = Selection1

Dim InputObjectType(0), Status
InputObjectType(0) = "CylindricalFace"
Status = selection2.SelectElement2(InputObjectType, "Select a Cylindrical Face:", True)

Dim reference1 As Reference
Set reference1 = Selection1.Item2(1).Reference

Dim hybridShapeAxis1 As HybridShapeAxisLine
Set hybridShapeAxis1 = hybridShapeFactory1.AddNewAxisLine(reference1)
body1.InsertHybridShape hybridShapeAxis1

part1.InWorkObject = hybridShapeAxis1
part1.Update

RE: Use Step Product file in scripting references??

seems like hybridShapeFactory1 is not defined

check catiav5automation.chm in order to define HybridShapFactory (or google it)

Eric N.
indocti discant et ament meminisse periti

RE: Use Step Product file in scripting references??

(OP)
i defined it in upper part of code not shown here.

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