×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Fixing the sketches

Fixing the sketches

Fixing the sketches

(OP)
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

RE: Fixing the sketches

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

https://picasaweb.google.com/102257836106335725208

RE: Fixing the sketches

(OP)

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

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources