Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TugboatEng on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Catia V5 active sketch macro

Status
Not open for further replies.

OskuLu

Mechanical
Joined
Mar 14, 2016
Messages
2
Location
FI
Hello,

Would someone write example script how to draw geometry to active sketch. Is it even possible? I need to draw circle diameter 2mm to point where I click with mouse.
 
Hi,

Sample from Dieter Ziethen book

Code:
' Version:		1.0
' Code:		CATIA CATScript
' Zweck:		Beispiel fur die Erzeugung einer Skizze mit verknĂĽpfter Geometrie
' Vorbereitung:	keine
' Autor:		Dieter Ziethen

CATIA.StatusBar = "CATScript, Version 1.0"

Sub CATMain ()

' Neues CATPart anlegen --------------------------------------------
Dim Bauteil As Part
Dim Dokument As Document
Set Dokument = CATIA.Documents.Add ("Part")
Set Bauteil = Dokument.Part

' Listenobjekt Sketches erzeugen -----------------------------------
Dim Skizzen As Sketches
Set Skizzen = Bauteil.MainBody.Sketches

' Referenzebene erzeugen -------------------------------------------
Dim UrsprungsElemente, Ebene
Set UrsprungsElemente = Bauteil.OriginElements
Set Ebene = UrsprungsElemente.PlaneYZ

' Objekt Sketch erzeugen -------------------------------------------
Dim Skizze As Sketch
Set Skizze = Skizzen.Add (Ebene)

' 2D-Werkzeugkasten erzeugen und Skizze Offnen ---------------------
Dim Wzk As Factory2D
Set Wzk = Skizze.OpenEdition

' Geometrie erzeugen und Linien verknĂĽpfen -------------------------
Dim Punkt (4) As Point2D
Dim Linie (4) As Line2D 
Set Punkt(1) = Wzk.CreatePoint (50, 50)
Set Punkt(2) = Wzk.CreatePoint (-50, 50)
Set Punkt(3) = Wzk.CreatePoint (50, -50)
Set Punkt(4) = Wzk.CreatePoint (-50, -50)
Set Linie(1) = Wzk.CreateLine (-50, 50, 50, 50)
Linie(1).StartPoint = Punkt(2)
Linie(1).EndPoint = Punkt(1)
Set Linie(2) = Wzk.CreateLine (50, 50, 50, -50)
Linie(2).StartPoint = Punkt(1)
Linie(2).EndPoint = Punkt(3)
Set Linie(3) = Wzk.CreateLine (50, -50, -50, -50)
Linie(3).StartPoint = Punkt(3)
Linie(3).EndPoint = Punkt(4)
Set Linie(4) = Wzk.CreateLine (-50, -50, -50, 50)
Linie(4).StartPoint = Punkt(4)
Linie(4).EndPoint = Punkt(2)

' Skizze schlieĂźen und Bauteil aktualisieren -----------------------
Skizze.CloseEdition
Bauteil.Update

End Sub

Regards
Fernando

- Romania
- EU
 
Ferdo, thank you for example code, but that is not what I looking for. I probably explained unclearly my needs. I need to make new tool to sketcher. Same kind of circle tool, but I need to make only 2mm diameter circles.

 
you can create a button and assign a macro to that button.
 
Did you try to record that action? (to create 2mm diameter circle in active sketch)

Did you look into v5automation.com? (to create point at cursor selection)

Why don't you post your code here and explain where your problem is?

you might actually get some help...

Eric N.
indocti discant et ament meminisse periti
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top