Das Wissen aller Anwender nutzen

Im Allplan Connect Forum tauschen sich Anwender aus, geben wertvolle Tipps oder beraten sich bei ganz konkreten Aufgabenstellungen − auch international.
Und damit wirklich keine Frage unbeantwortet bleibt, unterstützen die Mitarbeiter des Technischen Supports ebenfalls aktiv das Forum.

Es erwarten Sie:

  • Foren-Vielfalt aus CAD Architektur, CAD Ingenieurbau uvm.
  • Tipps von User für User
  • international: Deutsch, Englisch, Italienisch, Französisch und Tschechisch

Melden Sie sich jetzt an und diskutieren Sie mit!

Zur Registrierung

Set Layer State with PythonPart

Schlagworte:
  • Layer
  • Pythonpart
  • Model

I would like to control the layer state in the model using a PythonPart.
The method "LayerService" cannot be used to control the layer state directly. However, the layer state can be set with LayerService.LoadFromFavoriteFile and LayerService.SaveToFavoriteFile.
But I would like to control the layer status in the model directly. In particular, I would like to isolate a specific layer, i.e. set it to active and hide all other layers.
Is there a way to do this?
Or is this not yet integrated into the API interface?

I would be delighted if someone could give me an advice.
Regards Diego

Hi Diego,

Isolating a single layer in the sense of changing the layer status is not possible through the LayerService.

But if you only need to hide the elements during the runtime of a PythonPart, then you could use HideElementsService. Alternatively, the VisibleService - the service that stands behind the HideElementsService. You could then hide all the elements you don't want (e.g. all, whose layer does not equal the one you want to isolate). This is not directly the functionality of isolating the layer - you are hiding elements, not layers. But it quite covers your use-case, right?

Best,
Bart

Questions:
If you have made elements invisible and then quit the PythonPart without making them visible again: Do the elements remain “invisible”? For how long? Does the user have the option of making them visible again using Allplan tools?

Zitiert von: Nemo
If you have made elements invisible and then quit the PythonPart without making them visible again: Do the elements remain “invisible”?

Yes, the elements remain invisible. So I would like to emphasize: if you only need to hide the elements during the runtime of the PythonPart. It implies, that you, as a PythonPart developer, must show the elements before the PythonPart is terminated (i.e. in the on_cancel_function).

Zitiert von: Nemo
For how long?

Up until the loaded drawing file stack changes.

Zitiert von: Nemo
Does the user have the option of making them visible again using Allplan tools?

Yes, but not through a dedicated function. He/she can do it by changing the loaded drawing file stack (load or unload any DF) or calling "Reorganize Drawing files" (CTRL+F5 by default).

Hi Bart

Many thanks for the feedback and the suggestion to use the HideElementsService.

When I create complex 3D drawings, I often isolate individual drawing elements so that I can edit them easely. I also use this to ensure that I don't inadvertently change other drawing elements.
The visibility of the drawing elements can be controlled in Allplan, which I often use. However, although the drawing elements are not visible, they remain active in the background and can still be manipulated. I have therefore tried a solution with stricter isolation of the drawing elements via layers.

I use API to save the current layer of the drawing element to be isolated and set the element to the ‘Isolated’ layer. I can then isolate the layer and edit the drawing element. I use a second API to reset the layer of the isolated element to the original layer.

So your answer has helped me. I currently do the layer control with ‘SaveToFavourite’ or ‘LoadFromFavourite’. This is not so direct and elegant, but it works for the moment.

Best regards
Diego

Zitiert von: bmarciniec
Hi Diego,
Isolating a single layer in the sense of changing the layer status is not possible through the LayerService.
But if you only need to hide the elements during the runtime of a PythonPart, then you could use HideElementsService. Alternatively, the VisibleService - the service that stands behind the HideElementsService. You could then hide all the elements you don't want (e.g. all, whose layer does not equal the one you want to isolate). This is not directly the functionality of isolating the layer - you are hiding elements, not layers. But it quite covers your use-case, right?
Best,

Bart

Hi, I tried using HideElementsService and VisibleService in the API to hide the bar shape in the drawing, but it only affects the plan view. In the 3D view, the bar shape remains visible. Could you provide any advice?
Thank you

Zitiert von: Doom235
...I tried using HideElementsService and VisibleService in the API to hide the bar shape in the drawing, but it only affects the plan view. In the 3D view, the bar shape remains visible. Could you provide any advice?...

Hi!

That is, because you probably hide the wrong BaseElementAdapter. When you select a rebar in a plane view, what you get is the BaseElementAdapter of type BarsRepresentationLine_TypeUUID. When you hide it, you hide only a single rebar in a placement.

The parent element of if it, is an adapter of type BarsRepresentation_TypeUUID. When you hide this one, you hide the whole placement representation in the ground view or in one particular view or section (as you know, you can show the same placement in multiple views or sections).

The parent element of it is BarsLinearPlacement_TypeUUID (for a linear placement of course, for other placement types this would be different) and when you hide this one, you hide the placement in every UVS and in 3D

I found an example in my library, that uses the feature. It modifies the rebar placement. After you select a rebar placement, the placement itself is hidden and a preview of a new, modified placement is drawn. I hide the whole placement, on each UVS and in 3D, which is I think what you want to achieve.

But you never know, what the user selects. Under the ModifyBarPlacement class you'll find a method get_bar_placement. The method recursively goes up in the hierarchy and checks, if the parent is a placement. If yes, it returns it. If not, it goes one level up and again and again.

Have a look and let me know.

Best,
Bart

Anhänge (1)

Typ: application/zip
84-mal heruntergeladen
Größe: 3,45 KiB