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: 

Forma API: Render line in 3d scene

4 REPLIES 4
SOLVED
Reply
Message 1 of 5
paul_knokeMRKMH
610 Views, 4 Replies

Forma API: Render line in 3d scene

I was wondering How I render a line created via Forma API. This is my code:

 

 

async function App() {
  const line = await Forma.designTool.getLine();
}

 

 

In Forma I can then create a new line but when I hit enter to complete the creation the line disappears.

I guess I need to somehow render this line in the scene but I havent figuered out a way to do this.

Labels (2)
4 REPLIES 4
Message 2 of 5

Hi Paul.

 

There is no simple way to render a line in the API now.

The APIs you used under 'Forma.designTool' is intended for you to request the user to draw some geometry, that you will then use inside your extension. It will use the built in UI in Forma to do so, and will return the drawn line as geometry to the extension as showed in the example here

To render this line into the scene you have a few options. You can either create an element. This is used when you intend for the line to be persisted into the proposal the user is looking at, and affect analyses. For this you can either user the FloorStack or Integrate apis to first create an element and then the Proposal api to add this element to the scene. I do believe that the Integrate API accepts a Geojson structure and in this you should be able to pass LineStrings. 

Another option is to use the Render API. Either the Mesh or the GLB version. But neither of these make it very convenient to add lines. We do have a plan for a Geojson version which would make it easier to render lines onto the terrain.

 

I hope these pointers helps you in figuring this out, further than that I would love to hear what you intend to use this for so I could see what APIs that might be most suited, or learn what APIs are currently missing for your use case 🙂 Feel free to elaborate on your use case in this thread. 

Message 3 of 5

Hey Harvard,

 

I appreciate your suggestions. I will try it using a Geojson. At the moment, I don't have a particular use case in mind, rather I'm trying to get more familar with the forma api.

Message 4 of 5

Hello, guys I need something similar, I need to create a polygons or lines in 3d scene but I don't want use the desingTool, I only want to pass some coordinates and draw. do you have any suggestions.

 

Thank you so much

Message 5 of 5

For anyone landing on this issue, the option I mentioned above with a Geojson API is now available. 

See the docs here: https://app.autodeskforma.com/forma-embedded-view-sdk/docs/classes/render.RenderGeojsonApi.html

Here is a simple example:

import { Forma } from "forma-embedded-view-sdk/auto"

await Forma.render.geojson.add({
  geojson: {
    type: "FeatureCollection",
    features: [
      {
        type: "Feature",
        properties: {},
        geometry: {
          type: "LineString",
          coordinates: [
            [-100, -100],
            [100, 100],
          ],
        },
      },
    ],
  },
})

 

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

Post to forums  

Autodesk Design & Make Report