How do I delete an element from Hierarchy?

How do I delete an element from Hierarchy?

iklimis
Advocate Advocate
1,067 Views
7 Replies
Message 1 of 8

How do I delete an element from Hierarchy?

iklimis
Advocate
Advocate

Hello Forma team 

Using the following code I manage to create a squared shaped geoJson and add it as an Element in the Hierarchy
But I haven't found a way to actually remove it (or delete it) 

Keep in mind I have already tried using the RenderGeojsonApi for the geoJson and keeping the id for using it in the remove method but this approach is not helpful because I want to allow the user to reposition(dragging) the square via moving it with the mouse.

Basically what would be helpful is to use the element path to remove the element entirely (or the urn)

Thanks for the help!
Giannis

 

  async createSquareSelection() {
    const geoJson = this.createGeoJSONSquare({x: 0, y: 0}, 100);

    const {id, urn, revision}  = await this.formaService.forma.integrateElements.createElementHierarchy({
      data: {
        rootElement: "root",
        elements: {
          root: {
            id: "root",
            properties: {
              category: "site_limit",
              color: "#C4313D",
              geometry: {
                type: "Inline",
                format: "GeoJSON",
                geoJson: geoJson,
              },
            },
          },
        },
      },
    });

    const res = await this.formaService.forma.proposal.addElement({
      urn,
    });
  }

 

0 Likes
Accepted solutions (2)
1,068 Views
7 Replies
Replies (7)
Message 2 of 8

md_amjad_hossain
Autodesk
Autodesk

Hei @iklimis:

Right now, we dont support `removeElement` functionality. But, you can take a look at the `replaceElement` method. That, might satisfy your needs!!

But, I will raise an internal feature request to support the `removeElement`.

Thanks



Md Amjad Hossain
Software Development Engineer
0 Likes
Message 3 of 8

iklimis
Advocate
Advocate

Hey @md_amjad_hossain thanks for your reply!

Yes a removeElement() would provide a lot of help for this specific issue and for what I can imagine prove very helpful for future development ideas.

I have experimented with replaceElement() but that requires the need to create a mock object (an empty one..) and replacing it instead of just removing the element cleanly.

Regards
Giannis

0 Likes
Message 4 of 8

vilde.barth
Autodesk
Autodesk

@iklimis Do I understand correctly that you just want to temporary visualize the polygon? If so, you could use the Render GeoJSON API to preview the square and remove it when you do not want to show it anymore. By using this API, the preview is automatically removed when you close your extension, which is something that would be nice in your use case as well?

0 Likes
Message 5 of 8

iklimis
Advocate
Advocate

Hey@vilde.barth 
Already experimented with the render geoJson but in this particular case wasn't convenient because we would like for the user to be able to drag the square around in a position convenient for them.

The render geoJson doesnt allow that functionality.
The main goal is to allow the user to 'preview' the selection before they 'lock' it 

0 Likes
Message 6 of 8

vilde.barth
Autodesk
Autodesk
Accepted solution
I see, thanks for explaining!
0 Likes
Message 7 of 8

md_amjad_hossain
Autodesk
Autodesk
Accepted solution

Just a side note:

 

We do have `hideElement` and `unhideElement`, under `render` API, that absolutely could help you with your preview stuff!!

Thanks



Md Amjad Hossain
Software Development Engineer
0 Likes
Message 8 of 8

iklimis
Advocate
Advocate

You guys are the best!

0 Likes