API for Layer Hide/Show Everywhere

Pioneer
Pioneer

Hi,

 

Is there any direct API available for Hide/Show Everywhere command on Layer ?

 

 

Thanks,

Onkar

15 REPLIES

Re: API for Layer Hide/Show Everywhere

Solution Partner Legend Solution Partner Legend
Solution Partner Legend

Hi,

 

i don't know an equivalent command in the API.

 

So seems you have to iterate on your own through each sheet's Layers collection and search/set the desired layer's Show property to true/false.

 

Kind regards,
Wolfgang Kunert - www.wksyspro.de

Re: API for Layer Hide/Show Everywhere

Siemens Experimenter Siemens Experimenter
Siemens Experimenter

Thanks for the suggestion. I have already tried this one. But if in views I have used "Draw In View"command to insert geometries/annotatations then this is not working. Then use of Hide/Show Everywhere is also different for views with use of "Draw in View" command.

If you have any suggestion on this ;Please let me know.

 

Thanks. 

Re: API for Layer Hide/Show Everywhere

Solution Partner Legend Solution Partner Legend
Solution Partner Legend

Hi Onkar,

 

the DrawingView object owns the methods named HideLayer("layerName") and ShowLayer("layerName") with which you can hide/show the layers inside of a DrawingView object.

 

So you have to iterate over each sheet's DrawingViews collection and call for each DrawingView object one of the above mentioned methods to hide/show a specific layer.

 

By the way, the behaviour of Hide/Show Everywhere for the sheet layers can be accomplished too by

    Application.StartCommand(35007)

as noted in an older thread here.

 

Kind regards,
Wolfgang Kunert - www.wksyspro.de

Re: API for Layer Hide/Show Everywhere

Siemens Experimenter Siemens Experimenter
Siemens Experimenter

Hi,

Thanks for the reply.

Here this API are working correctly but here there is also issue with GUI. The Layers are not getting disabled on using Hide Layer.

 

Also this  functionlaity is different than the Hide/Show Everywhere on Layer.

I am working with'Draw in view'command in Drawing views.

 

 

Thanks,

Onkar

Re: API for Layer Hide/Show Everywhere

Solution Partner Legend Solution Partner Legend
Solution Partner Legend

Onkar,

 

as I've written above, the GUI Hide/Show Everywhere works for sheet layers only. As you observed, the hidden/shown status of layers in drawing views doesn't get changed by this GUI command.

 

To achieve the functionality you want, you have to do the following in abstract:

 

Iterate over all foreground and background sheets of your dft document

   Iterate over each sheet's Layers collection

       Set the Show property for the Layer object as you need it to be

  

   Iterate over each sheet's DrawingViews collection

       Execute the DrawingView object method HideLayer/ShowLayer as you need it to be

 

 

 

 

Kind regards,
Wolfgang Kunert - www.wksyspro.de

Re: API for Layer Hide/Show Everywhere

Siemens Experimenter Siemens Experimenter
Siemens Experimenter

Hi,

I have checked this but this is not working for me. Here I am working with 'Draw in view 'command.

 

I have attached one sample part. From drawing try to hide the "DrawInLayer" layer.

 

Thanks,

Onkar

 

Used Version is SolidEdge ST7

Re: API for Layer Hide/Show Everywhere

Solution Partner Legend Solution Partner Legend
Solution Partner Legend

Onkar,

 

with your sample I don't see a problem at all to hide a specific layer really everywhere. Even by GUI the command Hide Everywhere works properly on layers in views too.

 

Here a short VB.NET example how to achieve the same results per API:

 

Sub Main()

        Const layerNameToHide As String = "DrawInLayer"

        Dim seApp As SolidEdgeFramework.Application = GetObject(, "SolidEdge.Application")
        Dim dftDoc = CType(seApp.ActiveDocument, SolidEdgeDraft.DraftDocument)

        For Each layer As SolidEdgeFramework.Layer In dftDoc.ActiveSheet.Layers
            Select Case layer.Name
                Case layerNameToHide
                    layer.Show = False
                    Exit For
            End Select
        Next

        For Each dv As SolidEdgeDraft.DrawingView In dftDoc.ActiveSheet.DrawingViews
            Try
                dv.HideLayer(layerNameToHide)
            Catch ex As Exception

            End Try
        Next

        If dftDoc IsNot Nothing Then
            Marshal.FinalReleaseComObject(dftDoc)
            dftDoc = Nothing
        End If

        If seApp IsNot Nothing Then
            Marshal.FinalReleaseComObject(seApp)
            seApp = Nothing
        End If

End Sub

 

Result after execution with your above dft file opened in Solid Edge:

 

Layers.PNG

The layer named DrawInLayer is hidden everywhere Smiley Happy

Kind regards,
Wolfgang Kunert - www.wksyspro.de

Re: API for Layer Hide/Show Everywhere

Siemens Experimenter Siemens Experimenter
Siemens Experimenter

Hi Wolfgang,

 

This is giving correct result to me.But still in my case the GUI issue after using command

View.HideLayer("LayerName") is still there.

I have tried with vb as well C# .net codes.That is still minor issue.Smiley Happy

 

Earlier I have used either of them combination thats why getting different results.

 

Thanks,

Onkar  

Re: API for Layer Hide/Show Everywhere

Solution Partner Legend Solution Partner Legend
Solution Partner Legend

Onkar,

 

can you please explain your open issue more in detail. I don't understand what's not working in your case.

 

If you don't have any issues, you could mark this thread as solved Smiley Wink

Kind regards,
Wolfgang Kunert - www.wksyspro.de