You are on page 1of 11

Imports INFITF

Imports MECMOD

Imports PARTITF

Imports HybridShapeTypeLib

Imports CATOBM

Imports OSMInterfacesTypeLib

Imports System

Imports CATMat

Imports CATMultiCAD

Imports CATRma

Imports KnowledgewareTypeLib

Module module1

Dim pApplication As Application

Sub main()

connect()

create_circle()

End Sub

Sub connect()

pApplication = Getobject(, "CATIA.Application")

If pApplication Is Nothing Then

Console.WriteLine("Please open to CATIA")

End If

End Sub

Sub create_circle()

Dim documents1 As Documents


documents1 = pApplication.Documents

Dim partdocument1 As PartDocument

partdocument1 = documents1.Add("Part")

Dim part1 As Part

part1 = partdocument1.Part

Dim bodies1 As Bodies

bodies1 = part1.Bodies

Dim body1 As Body

body1 = bodies1.Item("PartBody")

Dim sketches1 As Sketches

sketches1 = body1.Sketches

Dim shapefactory1 As ShapeFactory

shapefactory1 = part1.ShapeFactory

Dim ref1 As Reference

ref1 = part1.OriginElements.PlaneXY

Dim sketch1 As Sketch

sketch1 = sketches1.Add(ref1)

Dim sketch2 As Sketch


sketch2 = sketches1.Add(ref1)

Dim ge1 As GeometricElements

ge1 = sketch1.GeometricElements

Dim constraints1 As Constraints

constraints1 = sketch1.Constraints

Dim factory2D1 As Factory2D

factory2D1 = sketch1.OpenEdition()

Dim cir As GeometricElement

cir = factory2D1.CreateClosedCircle(0, 0, 20)

Dim circle2D1 = ge1.Item("Circle.1")

Dim refcir As Reference

refcir = part1.CreateReferenceFromObject(circle2D1)

Dim pad1 As Pad

pad1 = shapefactory1.AddNewPad(sketch1, 30)

Dim const1 As Constraint

const1 = constraints1.AddMonoEltCst(CatConstraintType.catCstTypeRadius, refcir)

const1.Dimension.Value() = 30

Dim parameters1 As Parameters


parameters1 = part1.Parameters

Dim pm1 As Parameter

pm1 = parameters1.CreateDimension("Radius", "LENGTH", 50)

pm1.value() = 100

Dim pm2 As Parameter

pm2 = parameters1.CreateDimension("Height", "LENGTH", 50)

Dim Constraint2 As Constraint

Constraint2 = constraints1.Item("Radius.1")

Dim relation1 As Relations

relation1 = part1.Relations

Dim formula1 As Formula

formula1 = relation1.CreateFormula("Formula.1", "", Constraint2.Dimension, "Radius")

Dim lmt1 As Limit

lmt1 = pad1.FirstLimit

Dim height1 As Dimension

height1 = lmt1.Dimension

Dim formula2 As Formula

formula2 = relation1.CreateFormula("Formula.2", "", height1, "Height")


'Dim sketch1 As Sketch

'sketch1 = sketches1.Add(part1.OriginElements.PlaneXY)

'Dim pocket1 As Shape

'pocket1 = shapefactory1.AddNewPocket(sketch2, 60)

'pocket1.SetDirection(ref1)

''pocket1.IsSymmetric = True

'pocket1.IsThin = True

'Dim lmt1 As Limit

'lmt1 = pocket1.SecondLimit

'Dim length1 As Dimension

'length1 = lmt1.Dimension

'length1.Value = 30

sketch1.CloseEdition()

part1.Update()

'Dim circle As GeometricElement

'circle = sketch1.OpenEdition().CreateClosedCircle(0, 0, 20)

''sketch1.CloseEdition()
'part1.Update()

'Dim shapefactory1 As ShapeFactory

'shapefactory1 = part1.ShapeFactory

'Dim pad1 As Shape

'pad1 = shapes1.Item("Pad.1")

'pad1.Setdirection(ref1)

'Dim axis1 As GeometricElement

'axis1 = ge1.Item("AbsoluteAxis")

'Dim pt1 As GeometricElement

'pt1 = axis1.GetItem("Origin")

'Dim ref2 As Reference

'ref2 = part1.CreateReferenceFromObject(pt1)

'Dim hsf1 As HybridShapeFactory

'hsf1 = part1.HybridShapeFactory

'Dim pt2 As HybridShape

'pt2 = hsf1.AddNewPointCoord(-20, 0, 50)

'Dim ref3 As Reference

'ref3 = part1.CreateReferenceFromObject(pt2)
'Dim line1 As HybridShape

'line1 = hsf1.AddNewLinePtPt(ref2, ref3)

'Dim ref5 As Reference

'ref5 = part1.CreateReferenceFromObject(line1)

'Dim pad1 As Shape

'pad1 = shapefactory1.AddNewPad(sketch1, 30)

'pad1.SetDirection(ref5)

'pad1.IsSymmetric = True

'Dim hole1 As Shape

'hole1 = shapefactory1.AddNewHoleFromPoint(0, 0, 0, ref1, 20)

'hole1.reverse()

'part1.Update()

End Sub

Sub Add_Parameters()

'Dim documents1 As Documents

'documents1 = pApplication.Documents

'Dim partdocument1 As PartDocument

'partdocument1 = documents1.Add("Part")
'Dim part1 As Part

'part1 = partdocument1.Part

'Dim bodies1 As Bodies

'bodies1 = part1.Bodies

'Dim body1 As Body

'body1 = bodies1.Item("PartBody")

'Dim sketches1 As Sketches

'sketches1 = body1.Sketches

'Dim ref1 As Reference

'ref1 = part1.OriginElements.PlaneXY

'Dim sketch1 As Sketch

'sketch1 = sketches1.Add(ref1)

'Dim Factory2D1 As Factory2D

'Factory2D1 = sketch1.OpenEdition()

'Dim ge1 As GeometricElements

'ge1 = sketch1.GeometricElements

'Dim constraints1 As Constraints

'constraints1 = sketch1.Constraints
'Dim parameters1 As Parameters

'parameters1 = part1.Parameters

'Dim pm1 As Parameter

'pm1 = parameters1.CreateString("Text", "Learning")

'Dim pm2 As Parameter

'pm2 = parameters1.CreateDimension("Height", "LENGTH", 100)

'Dim pm3 As Parameter

'pm3 = parameters1.CreateDimension("Width", "LENGTH", 50)

'Dim pm4 As Parameter

'pm4 = parameters1.CreateDimension("Length", "LENGTH", 100)

'Dim line1 As GeometricElement

'line1 = Factory2D1.CreateLine(0, -20, -20, -20)

'Dim refline As Reference

'refline = part1.CreateReferenceFromObject(line1)

'line2 = Factory2D1.CreateLine(30, 0, 30, 30)

'Dim pt1, pt2 As GeometricElement

'pt1 = Factory2D1.CreatePoint(0, 0)

'pt2 = Factory2D1.CreatePoint(30, 30)


'Dim ptr1, ptr2 As Reference

'ptr1 = part1.CreateReferenceFromObject(pt1)

'ptr2 = part1.CreateReferenceFromObject(pt2)

'Dim Constraint3 As Constraint

'Constraint3 = constraints1.AddMonoEltCst(CatConstraintType.catCstTypeLength, line2D3)

'Constraint3.Mode = CatConstraintMode.catCstModeDrivingDimension

'Dim axis2D1 = ge1.Item("AbsoluteAxis")

'Dim line2D2 = axis2D1.GetItem("HDirection")

'Dim reference3 = part1.CreateReferenceFromObject(line2D2)

'Dim line2D3 = ge1.Item("Line.1")

'Dim ref8 As Reference

'ref8 = part1.CreateReferenceFromObject(line2D3)

'Dim constraint1 As Constraints

'constraint1 = constraints1.AddTriEltCst(CatConstraintType.catCstTypeSymmetry, ref8, refline,


reference3)

'Dim line6 As GeometricElement

'line6 = ge1.Item("Line.1")

'Dim ref6 As Reference

'ref6 = part1.CreateReferenceFromObject(line6)
'Dim Constraint2 As Constraint

'Constraint2 = constraints1.Item("Length.1")

'Dim relation1 As Relations

'relation1 = part1.Relations

'Dim formula1 As Formula

'formula1 = relation1.CreateFormula("Formula.1", "", Constraint2.Dimension, "Length")

'sketch1.CloseEdition()

'part1.Update()

End Sub

End Module

You might also like