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 cowski on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Fixing the sketches

Status
Not open for further replies.

sriram99

Aerospace
Joined
Dec 10, 2012
Messages
35
Location
IN
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
 
Hi,

I suggest you to run the code in vba editor step by step and watch in the same time on CATIA screen (expand the sketch tree on geometry and see what is going on).

But before this, try to fix another issue, what is happening if a user delete a sketch before and never recreated ? For example sketch.1 and sketch.2 are not existing in spec tree....

I suggest also to use sel.Search ("Type = point + line + curve")

Then check how good is working SendKeys method because I suppose there you have the problem. I suspect that CATIA is exiting from Sketch faster then SendKeys method and thats why the Fix Toghether is not created.

Regards
Fernando

 

Thank you Fernando,

As you said the problem is with send keys. Is there any other way to activate Fix Together window and press OK button?

regards,
Sriram

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top