sriram99
Aerospace
- Dec 10, 2012
- 35
Hi everyone,
Instead of constraing the sketch using dimensions I want to fix the sketches using fix together and I thought of doing this using a macro which will count the number of sketches in a part and fix them. After some googling I came up with a code, however it is working at the last it is deleting the fix together. I can't able to figure out what is wrong in the code. Please help me finding that.
Here is the code:
Sub CATMain()
Dim parRoot As PartDocument
Set prtRoot = CATIA.ActiveDocument
Dim sel As Selection
Set sel = prtRoot.Selection
sel.Search ("Name = Sketch.*")
C = sel.Count
For i = 1 To C
sel.Search ("Name = Sketch." & i)
CATIA.StartCommand ("Sketch")
sel.Search ("Type = point")
sel.Search ("Type = Line")
sel.Search ("Type = curve")
CATIA.StartCommand ("Fix Together")
sel.Search ("Name = HDirection")
sel.Search ("Name = VDirection")
Dim objShell
Set objShell = CreateObject("WScript.Shell")
CATIA.RefreshDisplay = True
objShell.SendKeys "{TAB}"
objShell.SendKeys "{TAB}"
objShell.SendKeys "{ENTER}"
CATIA.StartCommand ("Exit workbench")
Next i
End Sub
Thanks in advance
Instead of constraing the sketch using dimensions I want to fix the sketches using fix together and I thought of doing this using a macro which will count the number of sketches in a part and fix them. After some googling I came up with a code, however it is working at the last it is deleting the fix together. I can't able to figure out what is wrong in the code. Please help me finding that.
Here is the code:
Sub CATMain()
Dim parRoot As PartDocument
Set prtRoot = CATIA.ActiveDocument
Dim sel As Selection
Set sel = prtRoot.Selection
sel.Search ("Name = Sketch.*")
C = sel.Count
For i = 1 To C
sel.Search ("Name = Sketch." & i)
CATIA.StartCommand ("Sketch")
sel.Search ("Type = point")
sel.Search ("Type = Line")
sel.Search ("Type = curve")
CATIA.StartCommand ("Fix Together")
sel.Search ("Name = HDirection")
sel.Search ("Name = VDirection")
Dim objShell
Set objShell = CreateObject("WScript.Shell")
CATIA.RefreshDisplay = True
objShell.SendKeys "{TAB}"
objShell.SendKeys "{TAB}"
objShell.SendKeys "{ENTER}"
CATIA.StartCommand ("Exit workbench")
Next i
End Sub
Thanks in advance