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.
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??
The CylindricalFace object is not defined.
the face is in the selection.item(1) oject.
you can create the reference with the following:
CODE -->
also:
CODE -->
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 -->
but you don't check the status before using the resulting selection... ?!? what if the user press "Cancel"?
indocti discant et ament meminisse periti
RE: Use Step Product file in scripting references??
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??
check catiav5automation.chm in order to define HybridShapFactory (or google it)
indocti discant et ament meminisse periti
RE: Use Step Product file in scripting references??