×
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

Macro to select node in tree then Activate for editing

Macro to select node in tree then Activate for editing

Macro to select node in tree then Activate for editing

(OP)
We have a fairly consistent tree that is generated by another process. What I would like to do is create a macro that will select a node that is two levels down, expand it, then activate it for editing.

I've tried a few things, but nothing seems to activate the node (like a double-click would). I do have most of it working in catvba. Anybody have some catvba that would help activate the node?

RE: Macro to select node in tree then Activate for editing

Quote:

then activate it for editing

Is it supposed to be the final result of Your macro OR activation is necessary to start another procedure (e.g constraining child of active component? ?

Solutions:
If case
1. - There is no need to activate object by double-click on it (as node on tree)
2. - You can select desired object (through macro) and start appropriate workbench by CATIA.StartWorkbench("Part Design") command

LukaszSz. Poland, Warsaw University of Technology, Faculty of Power and Aeronautical Engineering : MEchanical Engineering. BsC - 2013

RE: Macro to select node in tree then Activate for editing

alternative solution for scenario 2

You have to create external Shell script that activate node (object to activate must be selected) and save it as vbs file

in this case filename is: "D:\ActivateNode.vbs"

CODE -->

Set WshShell = WScript.CreateObject("WScript.Shell")
WScript.sleep 200
WshShell.SendKeys "c:FrmActivate" + "{ENTER}", True 



In Yours Catia macro:

CODE -->

'...
AppActivate "CATIA V5"
StartCMD = "wscript D:\ActivateNode.vbs "
Call Shell(StartCMD)
'... 

LukaszSz. Poland, Warsaw University of Technology, Faculty of Power and Aeronautical Engineering : MEchanical Engineering. BsC - 2013

RE: Macro to select node in tree then Activate for editing

(OP)
Thank you again Lukaszsz. I will give it a try.

We have some users that want to skip the double-click because each node under the VSYS_CHASSIS node represents a bill of material that needs to be positioned along a chassis frame rail. Expanding and activating the node allows them to save wear-and-tear on their fingers.

RE: Macro to select node in tree then Activate for editing

(OP)
Solution one in lukaszsz' post does not solve the problem and thus is not even a solution.

Why do you say Sendkeys is tricky?

RE: Macro to select node in tree then Activate for editing

Hi,

When I said first solution was thinking of something like this (lukaszsz gives you just some guides, no one has time enough to give a complete solution):

CODE --> CATScript

Language="VBSCRIPT"

Sub CATMain()

        Dim documents1 As Documents
        Set documents1 = CATIA.Documents

        Dim partDocument1 As Document
        Set partDocument1 = documents1.Item("VSYS_CHASSIS.CATPart")

        Dim part1 As Part
        Set part1 = partDocument1.Part

        Dim selectPart
        Set selectPart = CATIA.ActiveDocument.Selection
        Dim editPart
        Set editPart = partDocument1

        selectPart.Add(partDocument1.Part)
        CATIA.StartWorkbench("PrtCfg")
        selectPart.Clear()

        editPart.Activate()
        
End Sub 

SendKeys is tricky because you need to find how many seconds you should delay the execution (or maybe is not necessary), maybe you have another process on your computer which can interfere with SendKeys command, a.s.o.

Regards
Fernando

https://picasaweb.google.com/102257836106335725208
https://picasaweb.google.com/103462806772634246699...

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