Language="VBSCRIPT" Sub CATMain() msgbox "Start creating an assembly" ' Creates a CATProduct Dim PrDoc0 As Document Set PrDoc0 = CATIA.Documents.Add ( "Product" ) ' Retrieves the root product Dim Prod1 As Product Set Prod1 = PrDoc0.Product ' Adds the KwrCap1.CATPart existing component to the product Dim var1 ( 0 ) var1 ( 0 ) = "E:\www\crecxr5\BasEnglish\basug.doc\src\samples\KwrCap1.CATPart" Prod1.Products.AddComponentsFromFiles var1, "*" ' Adds the KwrTipCreateAssembly.CATPart existing component to the product Dim var2 ( 0 ) var2 ( 0 ) = "E:\www\crecxr5\BasEnglish\basug.doc\src\samples\KwrTipCreateAssembly.CATPart" Prod1.Products.AddComponentsFromFiles var2, "*" ' Retrieves the Connections collection Dim CstS1 As Collection Set CstS1 = Prod1.Connections("CATIAConstraints") ' ------------------------------------------------------------------------ ' Creates an offset constraint ' ------------------------------------------------------------------------ ' ' a - Defines the first reference (Plane.1) ' Plane.1 is a plane through the planar curve defined by ' the bottle neck extremity ' ----------------------------------------------------------- Dim Ref1 As Reference Set Ref1 = Prod1.CreateReferenceFromName ( "Product1/Bottle.1/!Plane.1" ) ' b - Defines the second reference (the Pad.2 face to be set parrallel ' to Plane.1 ' ----------------------------------------------------------- Arg1aRef2 = "(Face:(Brp:(Pad.2;1);None:());EdgeFillet.2_ResultOUT)" Arg1Ref2 = "Product1/Cap1.1/!Selection_RSur:" & Arg1aRef2 Dim Ref2 As Reference Set Ref2 = Prod1.CreateReferenceFromName ( Arg1Ref2 ) msgbox "Create the offset constraint" ' Creates a 1 mm offset between Pad.2(on the cap) and Plane.1 Dim Cst2 As Constraint Set Cst2 = CstS1.AddBiEltCst ( 1, Ref1, Ref2 ) Cst2.Dimension.Value = 1.000000 Cst2.Orientation = 2 ' Updates the document Prod1.Update ' ------------------------------------------------------------------------- ' Creates a coaxiality constraint ' ------------------------------------------------------------------------- ' ' a - Defines the bottle axis as the first reference ' -------------------------------------------------- Arg1aRef3 = "(Face:(Brp:(GSMRevol.1;0:(Brp:(Sketch.1;1)));None:());GSMAssemble.1)" Arg1Ref3 = "Product1/Bottle.1/!Axis:(Selection_RSur:" & Arg1aRef3 & ")" Dim Ref3 As Reference Set Ref3 = Prod1.CreateReferenceFromName (Arg1Ref3) ' b - Defines the cap axis as the second reference ' -------------------------------------------------- Arg1aRef4 = "(Face:(Brp:(Pad.2;0:(Brp:(Sketch.2;4)));None:());EdgeFillet.2_ResultOUT)" Arg1Ref4 = "Product1/Cap1.1/!Axis:(Selection_RSur:" & Arg1aRef4 & ")" Dim Ref4 As Reference Set Ref4 = Prod1.CreateReferenceFromName ( Arg1Ref4 ) msgbox "Create the coincidence constraint" ' Specifies the coaxiality between the two axes above mentioned Dim Cst3 As Constraint Set Cst3 = CstS1.AddBiEltCst ( 2, Ref3, Ref4 ) Prod1.Update End Sub