-
1
- #1
Hi,
I recorded set of macros for inserting primitives into part.
I prepared Toolbar, even icon for cone... It works... but only when i'm inserting primitives to part. When i'm trying insert it to part which is inside Product i have error in line :
Set part1 = partDocument1.Part
(Object doesn't support this property or method).
I can record second set of macros especialy for Product, but I would like to learn how to make this macro more universal.
Language="VBSCRIPT"
Sub CATMain()
Set partDocument1 = CATIA.ActiveDocument
Set part1 = partDocument1.Part
Set bodies1 = part1.Bodies
Set body1 = bodies1.Item(1)
Set sketches1 = body1.Sketches
Set originElements1 = part1.OriginElements
Set reference1 = originElements1.PlaneYZ
Set sketch1 = sketches1.Add(reference1)
Dim arrayOfVariantOfDouble1(8)
arrayOfVariantOfDouble1(0) = 0.000000
arrayOfVariantOfDouble1(1) = 0.000000
arrayOfVariantOfDouble1(2) = 0.000000
arrayOfVariantOfDouble1(3) = 0.000000
arrayOfVariantOfDouble1(4) = 1.000000
arrayOfVariantOfDouble1(5) = 0.000000
arrayOfVariantOfDouble1(6) = 0.000000
arrayOfVariantOfDouble1(7) = 0.000000
arrayOfVariantOfDouble1(8) = 1.000000
sketch1.SetAbsoluteAxisData arrayOfVariantOfDouble1
part1.InWorkObject = sketch1
Set factory2D1 = sketch1.OpenEdition()
Set geometricElements1 = sketch1.GeometricElements
Set axis2D1 = geometricElements1.Item("AbsoluteAxis")
Set line2D1 = axis2D1.GetItem("HDirection")
line2D1.ReportName = 1
Set line2D2 = axis2D1.GetItem("VDirection")
line2D2.ReportName = 2
Set point2D1 = factory2D1.CreatePoint(0.000000, 140.000000)
point2D1.ReportName = 3
Set line2D3 = factory2D1.CreateLine(0.000000, 0.000000, 0.000000, 140.000000)
line2D3.ReportName = 4
Set point2D2 = axis2D1.GetItem("Origin")
line2D3.StartPoint = point2D2
line2D3.EndPoint = point2D1
Set constraints1 = sketch1.Constraints
Set reference2 = part1.CreateReferenceFromObject(line2D3)
Set reference3 = part1.CreateReferenceFromObject(line2D2)
Set point2D3 = factory2D1.CreatePoint(70.000000, -0.000000)
point2D3.ReportName = 5
Set line2D4 = factory2D1.CreateLine(-0.000000, 140.000000, 70.000000, -0.000000)
line2D4.ReportName = 6
line2D4.StartPoint = point2D1
line2D4.EndPoint = point2D3
Set line2D5 = factory2D1.CreateLine(70.000000, -0.000000, 0.000000, 0.000000)
line2D5.ReportName = 7
line2D5.StartPoint = point2D3
line2D5.EndPoint = point2D2
Set reference4 = part1.CreateReferenceFromObject(line2D5)
Set reference5 = part1.CreateReferenceFromObject(line2D1)
sketch1.CenterLine = line2D3
sketch1.CloseEdition
part1.InWorkObject = sketch1
part1.Update
Set shapeFactory1 = part1.ShapeFactory
Set shaft1 = shapeFactory1.AddNewShaft(sketch1)
part1.Update
End Sub
I recorded set of macros for inserting primitives into part.
I prepared Toolbar, even icon for cone... It works... but only when i'm inserting primitives to part. When i'm trying insert it to part which is inside Product i have error in line :
Set part1 = partDocument1.Part
(Object doesn't support this property or method).
I can record second set of macros especialy for Product, but I would like to learn how to make this macro more universal.
Language="VBSCRIPT"
Sub CATMain()
Set partDocument1 = CATIA.ActiveDocument
Set part1 = partDocument1.Part
Set bodies1 = part1.Bodies
Set body1 = bodies1.Item(1)
Set sketches1 = body1.Sketches
Set originElements1 = part1.OriginElements
Set reference1 = originElements1.PlaneYZ
Set sketch1 = sketches1.Add(reference1)
Dim arrayOfVariantOfDouble1(8)
arrayOfVariantOfDouble1(0) = 0.000000
arrayOfVariantOfDouble1(1) = 0.000000
arrayOfVariantOfDouble1(2) = 0.000000
arrayOfVariantOfDouble1(3) = 0.000000
arrayOfVariantOfDouble1(4) = 1.000000
arrayOfVariantOfDouble1(5) = 0.000000
arrayOfVariantOfDouble1(6) = 0.000000
arrayOfVariantOfDouble1(7) = 0.000000
arrayOfVariantOfDouble1(8) = 1.000000
sketch1.SetAbsoluteAxisData arrayOfVariantOfDouble1
part1.InWorkObject = sketch1
Set factory2D1 = sketch1.OpenEdition()
Set geometricElements1 = sketch1.GeometricElements
Set axis2D1 = geometricElements1.Item("AbsoluteAxis")
Set line2D1 = axis2D1.GetItem("HDirection")
line2D1.ReportName = 1
Set line2D2 = axis2D1.GetItem("VDirection")
line2D2.ReportName = 2
Set point2D1 = factory2D1.CreatePoint(0.000000, 140.000000)
point2D1.ReportName = 3
Set line2D3 = factory2D1.CreateLine(0.000000, 0.000000, 0.000000, 140.000000)
line2D3.ReportName = 4
Set point2D2 = axis2D1.GetItem("Origin")
line2D3.StartPoint = point2D2
line2D3.EndPoint = point2D1
Set constraints1 = sketch1.Constraints
Set reference2 = part1.CreateReferenceFromObject(line2D3)
Set reference3 = part1.CreateReferenceFromObject(line2D2)
Set point2D3 = factory2D1.CreatePoint(70.000000, -0.000000)
point2D3.ReportName = 5
Set line2D4 = factory2D1.CreateLine(-0.000000, 140.000000, 70.000000, -0.000000)
line2D4.ReportName = 6
line2D4.StartPoint = point2D1
line2D4.EndPoint = point2D3
Set line2D5 = factory2D1.CreateLine(70.000000, -0.000000, 0.000000, 0.000000)
line2D5.ReportName = 7
line2D5.StartPoint = point2D3
line2D5.EndPoint = point2D2
Set reference4 = part1.CreateReferenceFromObject(line2D5)
Set reference5 = part1.CreateReferenceFromObject(line2D1)
sketch1.CenterLine = line2D3
sketch1.CloseEdition
part1.InWorkObject = sketch1
part1.Update
Set shapeFactory1 = part1.ShapeFactory
Set shaft1 = shapeFactory1.AddNewShaft(sketch1)
part1.Update
End Sub