Macro programmation

30 novembre 2018

creation d'une esquisse suivant le planYZ

Sub CATMain()

dim partdocument1
set partdocument1=CATIA.ActiveDocument
dim part1 as Part
set part1 = partDocument1.Part
Dim bodies1 As Bodies
Set bodies1 = part1.Bodies
Dim body1 As Body
Set body1 = bodies1.Item("Corps principal")
Dim sketches1 As Sketches
Set sketches1 = body1.Sketches
Dim originElements1 As OriginElements
Set originElements1 = part1.OriginElements
Dim reference1 As AnyObject
Set reference1 = originElements1.PlaneYZ
Dim sketch1 As Sketch
Set sketch1 = sketches1.Add(reference1)
End Sub

Posté par ours_brun83 à 19:27 - Commentaires [0] - Permalien [#]


creation de set geometrique sous un corps ou apres le corps principal

Sub CATMain()
dim mybody
dim hbrid1,hbrid2
dim monset1,monset2
set mybody=catia.activedocument.part.Mainbody
set hbrid1=catia.activedocument.part.hybridbodies
set hbrid2=mybody.hybridbodies
set monset1 = hbrid1.add
set monset2=hbrid2.add

monset1.name="apres"
monset2.name="dessous"
End Sub

Posté par ours_brun83 à 18:17 - Commentaires [0] - Permalien [#]

ouverture d'une part avec chemin sur disque

Sub CATMain()
Dim documents 'As Documents
Set documents = CATIA.Documents
Dim partDocument 'As Document
Set partDocument = documents.Open("H:\macro\part_avec_plan.CATPart")
End Sub

Posté par ours_brun83 à 17:51 - Commentaires [0] - Permalien [#]

creation part et set geometrique

Sub CATMain()
Dim documents ' As Documents
Dim partDocument' As Document
Dim hybridBodies 'As HybridBodies
Dim hybridBody 'As HybridBody
Set documents = CATIA.Documents
Set partDocument = documents.Add("Part")
Set hybridBodies = catia.activedocument.part.HybridBodies
Set hybridBody = hybridBodies.add
End Sub

Posté par ours_brun83 à 17:12 - Commentaires [0] - Permalien [#]

creation d'une part

Sub CATMain()
Dim documents1 'As Documents
Dim partDocument1 'As Document
Set documents1 = CATIA.Documents
Set partDocument1 = documents1.Add("Part")
End Sub

Posté par ours_brun83 à 16:43 - Commentaires [0] - Permalien [#]

affiche le nom de la part active

Sub CATMain()
set mypart = catia.activedocument
msgbox(mypart.name)
End Sub

Posté par ours_brun83 à 16:35 - Commentaires [0] - Permalien [#]

creation d'un corps principal "Vis" dans une part.

Sub CATMain()
dim mybodies
set mybodies=catia.activedocument.part.bodies
dim vis
set vis = mybodies.add
vis.name="Vis"
End Sub

Posté par ours_brun83 à 16:31 - Commentaires [0] - Permalien [#]