CATIA VBA Drafting Workbench
CATIA VBA Drafting Workbench
(OP)
Does anyone know the code to run the Symmetry command on all geometry in a DXF? I already have code to open the DXFs and to select all 2D lines with a search in the Drawing object but haven't quite figured out the Symmetry portion yet; the Automation help for CATIA (V5 R23) doesn't really seem to list it.
Thanks all!
Thanks all!





RE: CATIA VBA Drafting Workbench
You can use CATIA.StartCommand "Symmetry" after selection, and CATIA will wait for you to pick up the symmetry axis.
Regards
Fernando
https://picasaweb.google.com/102257836106335725208 - Romania
https://picasaweb.google.com/103462806772634246699... - EU
RE: CATIA VBA Drafting Workbench
CODE --> VBA
Is there a declaration to only select simple 2D lines and not the axis lines?
RE: CATIA VBA Drafting Workbench
Regards
Fernando
https://picasaweb.google.com/102257836106335725208 - Romania
https://picasaweb.google.com/103462806772634246699... - EU
RE: CATIA VBA Drafting Workbench
Do you know what the search command is for the axis itself? I tried "2DAxis, VDirection" and "2DLine, VDirection" but no luck so far.
RE: CATIA VBA Drafting Workbench
If you create that line (symmetry) in your code then is much easier because you can change the name with a specific one (like mysymmline for example) and then you can use a search by name.
Regards
Fernando
https://picasaweb.google.com/102257836106335725208 - Romania
https://picasaweb.google.com/103462806772634246699... - EU
RE: CATIA VBA Drafting Workbench
CODE --> VBA
Just can't quite figure out the last bit here. I tried moving the Symmetry command up and down in the code but to no avail. Do I need to reactivate the sheet or something, like in Excel?
RE: CATIA VBA Drafting Workbench
CATIA.RefreshDisplay = True
AppActivate "CATIA V5"
SendKeys "c:Symmetry" + Chr(13), True
Application.Wait Now + TimeValue("00:00:10")
By the way, if you want to change the name of the line you have to
symLine.Name = "my_symLine"
Regards
Fernando
https://picasaweb.google.com/102257836106335725208 - Romania
https://picasaweb.google.com/103462806772634246699... - EU
RE: CATIA VBA Drafting Workbench
Both
CODE --> VBA
CODE --> VBA
RE: CATIA VBA Drafting Workbench
RE: CATIA VBA Drafting Workbench
Regards
Fernando
https://picasaweb.google.com/102257836106335725208 - Romania
https://picasaweb.google.com/103462806772634246699... - EU
RE: CATIA VBA Drafting Workbench
Either way, I made a loop delay Sub instead, and the 10 second pause doesn't help. The command still isn't completing.
When I figure out what's going on, I'll post the code back here.
RE: CATIA VBA Drafting Workbench
CODE --> vba
Sub CATMain() MsgBox "You have 10 seconds to pick elements to create their symmetry and the symmetry line. Look in lower left corner of CATIA window for instructions" On Error Resume Next Set objCATIA = GetObject(, "CATIA.Application") Dim drawingDocument1 As DrawingDocument Set drawingDocument1 = CATIA.ActiveDocument Dim DrwSht As DrawingSheet Set DrwSht = drawingDocument1.Sheets.ActiveSheet Dim DrwView As DrawingView Set DrwView = DrwSht.Views.ActiveView Dim fact As Factory2D Set fact = DrwView.Factory2D Dim symLine As Line2D Set symLine = fact.CreateLine(0, 0, 0, 5) CATIA.StartCommand (Symmetry) Dim selection3 As Selection Set selection3 = drawingDocument1.Selection selection3.Search "CATDrwSearch.2DLine,all" Dim selection4 As Selection Set selection4 = drawingDocument1.Selection selection4.Search "CATDrwSearch.2DLine,symLine" CATIA.ActiveDocument.Selection.Clear CATIA.RefreshDisplay = True CATIA.StartCommand "Symmetry" Dim time1, time2 time1 = Now time2 = Now + TimeValue("0:00:10") Do Until time1 >= time2 DoEvents time1 = Now() Loop MsgBox "Time passed 10 sec" End SubRegards
Fernando
https://picasaweb.google.com/102257836106335725208 - Romania
https://picasaweb.google.com/103462806772634246699... - EU
RE: CATIA VBA Drafting Workbench
I'm trying make this automatic, no user input. I have 1000's of DXFs to mirror and can't have someone sitting there clicking. Thus the attempt at selecting the "symLine" after selecting all the other 2D geometry.
I'll keep working on forcing this selection.
RE: CATIA VBA Drafting Workbench
CODE --> VBA
The text doesn't seem to mirror properly (the mirrored text is shifted slightly from its original position), indicating that there is some sort of offset applied to the text. That's the last bit I'll need to figure out.
RE: CATIA VBA Drafting Workbench
Regards
Fernando
https://picasaweb.google.com/102257836106335725208 - Romania
https://picasaweb.google.com/103462806772634246699... - EU
RE: CATIA VBA Drafting Workbench
CODE --> VBA
For i = 1 To DrwView.Texts.Count DrwView.Texts.Item(i).AnchorPosition = catMiddleRight NextAnd everything works now. Thanks for the help!