Show toolbars with VB
Show toolbars with VB
(OP)
I am learning SE automation in VB. I´ve already drawn a simple crankshaft, but I can´t get Principal and Operations toolbars opened with the PartDocument, so I lose my time opening them manually every time I draw the part.
Please help me ¿What can I do?
Please help me ¿What can I do?





RE: Show toolbars with VB
what do mean with 'Principal and Operations toolbars' ?
I've no knowledge what they are composed of (new in V18?)
that is I can't find them ...
dy
RE: Show toolbars with VB
maybe this is of help to you to find the name and set it:
Private oApp As SolidEdgeFramework.Application
Private oEnv As SolidEdgeFramework.Environment
Private oBar As SolidEdgeFramework.CommandBar
'
' needs a form with one button on it
' References: SolidEdge Constants/Framework/FrameworkSupport Type libs
Private Sub Command1_Click()
'
'
Set oApp = GetObject(, "SolidEdge.application")
Set oEnv = Nothing
'
' assumed a .par is open
Set oEnv = oApp.Environments("Part") ' part main environment
For Each oBar In oEnv.CommandBars
'
' show name of bars
MsgBox "Name " & oBar.Name & " visible: " & oBar.Visible
'
' if this is the one we --> show it
If LCase(oBar.Name) = "partfeatures" Then
oBar.Visible = True ' <- show bar
Exit For ' set to comment to cycle through all
End If
Next oBar
'
Set oBar = Nothing
Set oEnv = Nothing
Set oApp = Nothing
'
End Sub
=================
dy
RE: Show toolbars with VB
I am in Colombia, and I have the spanish version. The translations for the toolbars are "Principal" and "Operaciones", so I translated them back as they were.
"Operaciones" is the name of the toolbar where there are the protrusions, extrusions, mirrors, rounds, etc.
"Principal" is the name of the toolbar where there are the zoom, show edges, rotate, etc buttons.
I haven´t proved your post, but thanks. I will prove it right now.
RE: Show toolbars with VB
ah, that explains a lot.
Principal --> Main Tool Bar (MainTollbar)
Operaciones --> Features (PartFeatures)
Then the coding should work for you.
dY
RE: Show toolbars with VB
But I had to change some things
Took off the MsgBox, and had to create a counter to get out of the FOR when done. Took off the private estatements and converted to dim
The result was this
(Entorno=Environment, Barra = Bar)
Dim Entorno As SolidEdgeFramework.Environment
Dim Barra As SolidEdgeFramework.CommandBar
Dim counter As Integer
counter = 0
Set Entorno = Aplicacion.Environments("Part")
For Each Barra In Entorno.CommandBars
Barra.Visible = True
counter = counter + 1
If counter = 2 Then
Exit For
End If
Next Barra
RE: Show toolbars with VB
that's OK. There is, however, a drawback in that you always set to visible
the first 2 bars found. To be more flexible you could use the following
approach (only relevant part shown):
dy
============
Dim coNames As Collection
Dim sTemp As String
Set coNames = New Collection
coNames.AddItem "dummy", Key:="bar_name1" ' the key is the bar's name wanted and
coNames.AddItem "dummy", Key:="bar_name2" ' 'dummy' is a placeholder and not used
'
Counter = 0
For Each oBar In oEnv.CommandBars
'
' show name of bars
On Error Resume Next
sTemp = coNames.Item(LCase(Trim(oBar.Name)))
If Err.Number = 0 Then ' = 0 found and it's the one we want
oBar.Visible = True
Counter = Counter + 1
If Counter >= coNames.Count Then
Exit For
End If
End If
Err.Clear
Next oBar
RE: Show toolbars with VB
Oops! I mixed up something:
the add to collection must read:
coNames.Add "dummy", Key:="bar_name1" ' the key is the name wanted
coNames.Add "dummy", Key:="bar_name2" ' dummy is a placeholder and not used
AddItem belongs to something different, I apologize for any inconvenience
dY
RE: Show toolbars with VB
one addition:
if you compare the bar's name:
use oBar.Name to be language independend (always english)
use oBar.NameLocal to be language dependend (Spanish in your case)
dY