Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CATIA.StartCommand ("Center Graph") Problem

Status
Not open for further replies.

Catiaer

Mechanical
Nov 9, 2019
13
0
0
KR
Hello all,

Here is an example of CATIA.Startcommand that I found on the internet.
I tested in the part design workbench then it sometimes(?) works.
I mean that after I reopen a catia instance, it works.
But when I use it 2 or more, it doesn't work any more..
And in assembly work bench I could have never seen that it works.
I tried to use with sendkeys that I type "Center Graph" as command and press enter key.
Before I did it, I tested manually to type "Center Graph" and entered, it didn't work also.
But when I use center graph in the command list, it works gut very well in the both workbench.
And the other function seems to work well, ex) reframe on, hide and show, etc
Is there another way to use center graph?

Code:
Sub CATMain()

Dim oSel As Selection
Set oSel = CATIA.ActiveDocument.Selection

Dim Name As String
Name = InputBox("Please enter name of geometry to search for.")

'In next line selection will search for name from inputbox  inside all parts or products.
oSel.Search ("Name=" & Name & "*,all")
'When we made selection now we can use it
iCount = oSel.Count
MsgBox ("Number of shapes found: " & iCount)

For I = 1 To iCount
'    CATIA.StartCommand ("Collapse All")
    CATIA.StartCommand ("Center Graph")
'    CATIA.StartCommand "Center Graph"
Next
End Sub

'You can run this macro in part and product!!
 
Replies continue below

Recommended for you

of course, before I post here, I tried to search it in google first, and here also.
And I tried to all code with startcommand "center graph", but there is no good result.
 
I understand that loop, but only that center graph doesn't work, when I change it to fit all in or hide and show command, then it works. That is what I didn't understand.
 
Maybe this will guide you more, input the exact name just to show that the command is working. It will work in the same way in a loop.

Sub CATMain()

Dim oSel As Selection
Set oSel = CATIA.ActiveDocument.Selection
oSel.Clear

Dim Name As String
Name = InputBox("Please enter exact name of geometry to search for.")
oSel.Search ("Name_CAP=" & Name & ",all")

CATIA.StartCommand ("Center Graph")

End Sub

Regards
Fernando

 
Catiaer (Mechanical)(OP) is right.
"c:Center graph" works only if the active workbench is not assembly design.
.
.
.
Solved it !
You have to assign an user alias to this command and use that name in place of "center graph".
Works every time.
 
Status
Not open for further replies.
Back
Top