Symmetry command in macro for text
Symmetry command in macro for text
(OP)
Hi guys,
Can't seem to find a specific solution for this anywhere on the internet... Maybe you guys can help.
We use a macro here to create text and paste it onto an existing sketch in the part body. This macro works fine, but I want to tweak it a bit and flip the orientation of the text before pasting. This text is scribed into an ID plate which will leave an impression in the foam, therefore, the text must be reversed.
I've included the section of code that copies the text in a DXF file and pastes it onto the part sketch.
'Copy text---------------------------------------------------------------------------------------------------
'Set drawingDocument1 = CATIA.ActiveDocument
'Set selection1 = drawingDocument1.Selection
Set selection1 = drawingdocument2.Selection
selection1.Search "Name=Poly*,all"
selection1.copy
'Switch to Part again---------------------------------------------------------------------------------------
Original_part.activate
'msgbox "Now you can paste the text into a sketch"
'selection1.paste
selection2.Add sketch1
selection2.paste
set mypart=original_part.part
Thanks!
Can't seem to find a specific solution for this anywhere on the internet... Maybe you guys can help.
We use a macro here to create text and paste it onto an existing sketch in the part body. This macro works fine, but I want to tweak it a bit and flip the orientation of the text before pasting. This text is scribed into an ID plate which will leave an impression in the foam, therefore, the text must be reversed.
I've included the section of code that copies the text in a DXF file and pastes it onto the part sketch.
'Copy text---------------------------------------------------------------------------------------------------
'Set drawingDocument1 = CATIA.ActiveDocument
'Set selection1 = drawingDocument1.Selection
Set selection1 = drawingdocument2.Selection
selection1.Search "Name=Poly*,all"
selection1.copy
'Switch to Part again---------------------------------------------------------------------------------------
Original_part.activate
'msgbox "Now you can paste the text into a sketch"
'selection1.paste
selection2.Add sketch1
selection2.paste
set mypart=original_part.part
Thanks!





RE: Symmetry command in macro for text
RE: Symmetry command in macro for text
Could you be a bit more specific? I understand what "change sketch support" is and can perform this manually, but I'm unsure of the coding side. I have a very basic knowledge of programming languages and am not familiar with the syntax VBA uses.
Cheers,
RE: Symmetry command in macro for text
RE: Symmetry command in macro for text
I don't think you can create a positioned sketch in VBA. You can try programming the inversion to achieve a similar result.
CODE --> catvba
Dim sketch1 As Sketch Set sketch1 = sketches1.Item("Sketch.1") sketch1.InverseOrientationDrew Mumaw
www.textsketcher.com
www.drewmumaw.com
RE: Symmetry command in macro for text
Seem to be getting an issue with sketches1.Item. Compiler says Object required: 'sketches1'. Maybe I need to declare something?
RE: Symmetry command in macro for text
Yes. It's probably a declaration issue. Here's my full code for you to reference.
CODE --> catvba
Sub CATMain() Dim partDocument1 As PartDocument Set partDocument1 = CATIA.ActiveDocument Dim part1 As Part Set part1 = partDocument1.Part part1.Update Dim bodies1 As Bodies Set bodies1 = part1.Bodies Dim body1 As Body Set body1 = bodies1.Item("PartBody") Dim sketches1 As Sketches Set sketches1 = body1.Sketches Dim sketch1 As Sketch Set sketch1 = sketches1.Item("Sketch.1") sketch1.InverseOrientation part1.UpdateObject sketch1 End SubDrew Mumaw
www.textsketcher.com
www.drewmumaw.com
RE: Symmetry command in macro for text
The declaration for "Sketches" is still causing an issue. Specifically line 21 (set sketch1 = sketches1.Item("Sketch.1").
Now, I don't have much experience with programming, but I try to dissect it. Could the issue be that I do not put ANY sketches or GSD components inside bodies? I keep them in a separate Geometric Set. Seems like the declaration of sketches only looks inside the bodies, not geo sets.
RE: Symmetry command in macro for text
RE: Symmetry command in macro for text
Use Insert > Object resolution... and then select the sketch in the tree to see it's path.
Drew Mumaw
www.textsketcher.com
www.drewmumaw.com
RE: Symmetry command in macro for text
I tried manipulating my code, but something is still not working...
Sub CATMain()
dim partDocument1 As PartDocument
set partDocument1 = CATIA.ActiveDocument
dim part1 As Part
set part1 = partDocument1.Part
part1.update
dim bodies1 As HybridBodies
set bodies1 = part1.HybridBodies
dim body1 As Body
set body1 = bodies1.Item("Construction: ID Plate")
MsgBox body1.Name
dim sketches1 As Sketches
set sketches1 = body1.Sketches This is where the compiler stops and gives me an error.
MsgBox sketches1.Name
dim sketch1 As Sketch
set sketch1 = sketches1.Item("ID")
sketch1.InverseOrientation
End Sub
Really appreciate the help guys.
RE: Symmetry command in macro for text
Sub CATMain()
dim partDocument1 As PartDocument
set partDocument1 = CATIA.ActiveDocument
dim part1 As Part
set part1 = partDocument1.Part
'MsgBox part1.Name
dim hybridBodies1 As HybridBodies
set hybridBodies1 = part1.HybridBodies.Item(1)
'MsgBox hybridBodies1.Name
dim sketch1 As Sketch
set sketch1 = hybridBodies1.HybridSketches.Item("ID")
'MsgBox sketch1.Name
sketch1.InverseOrientation
part1.Update
End Sub
One question... This macro flips the orientation of the sketch along the X-axis. Is there a simple way to flip this sketch along the Y-axis?
RE: Symmetry command in macro for text
A helpful tip: put your cursor anywhere in your code and hit F1 to bring up the documentation for that code. This will come in handy when learning.
Drew Mumaw
www.textsketcher.com
www.drewmumaw.com
RE: Symmetry command in macro for text