Community
Forma Developer Forum
Welcome to Autodesk Forma Developer Forum. Share your knowledge, ask questions, and explore popular Forma API topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How do I delete an element from Hierarchy?

7 REPLIES 7
SOLVED
Reply
Message 1 of 8
iklimis
449 Views, 7 Replies

How do I delete an element from Hierarchy?

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,
    });
  }

 

Labels (1)
7 REPLIES 7
Message 2 of 8
md_amjad_hossain
in reply to: iklimis

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
Message 3 of 8
iklimis
in reply to: iklimis

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

Message 4 of 8
vilde.barth
in reply to: iklimis

@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?

Message 5 of 8
iklimis
in reply to: iklimis

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 

Message 6 of 8
vilde.barth
in reply to: iklimis

I see, thanks for explaining!
Message 7 of 8
md_amjad_hossain
in reply to: iklimis

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
Message 8 of 8
iklimis
in reply to: iklimis

You guys are the best!

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Forma Design Contest


Autodesk Design & Make Report