FormIt for Windows
English
English
  • Introduction
  • What's New
  • FormIt Capabilities
    • Multiple Clients
    • Conceptual Solid Modeling
    • Working with Data Formats
    • Languages
    • Collaboration
    • Presentation Graphics
    • FormIt + Autodesk Docs
    • FormIt + Dynamo
    • Solar + Energy Analysis
    • FormIt + Revit
    • FormIt + JavaScript for Plugins
  • FormIt Introduction
    • Frequently Asked Questions
    • Prerequisites and Installation
    • Setting Up the Project
    • Toolbars and Palettes
    • Navigating the Scene
  • FormIt Primer
    • Part I
      • 1.1 - Set the Location
      • 1.2 - Project Set Up with Images and Grid
      • 1.3 - 3D Sketch and Drag Face
      • 1.4 - Add Floors with Levels
      • 1.5 - Group Objects
      • 1.6 - Control Visibility with Layers
      • 1.7 - Paint with Materials
      • 1.8 - Create Columns with Array
      • 1.9 - Adding Details
      • 1.10 - Computational Groups with Dynamo
      • 1.11 - Import Models with Content Library
      • 1.12 - Visual Styles
      • 1.13 - Section Planes
      • 1.14 - Export Image
      • 1.15 - Working With Revit
    • Part II
      • 2.1 - Offset Line Tool
      • 2.2 - Advanced Modeling Tools: Shell and Cover
      • 2.3 Orthographic View Workflow
      • 2.4 - 3D Terrain Workflows
      • 2.5 - Plugins
      • 2.6 - Dynamo FormIt Nodes
      • 2.7 - Diagnostics Tools
      • 2.8 - Advanced Revit Workflows
      • 2.9 - Solar and Insight Energy Analysis
      • 2.10 - Collaboration Sessions
  • Tool Library
    • 3D Text
    • Align Camera With Face
    • Arc
    • Array
    • Array Along Path
    • AutoSave
    • Boolean Cut
    • Boolean Intersect
    • Boolean Join
    • Circle
    • Collaboration
    • Content Library
    • Copy Object
    • Cover, Sweep, Loft
    • Create Panorama
    • Curve + Surface Faceting
    • Delete, Edit, Move
    • Dynamo
    • Energy Analysis with Insight
    • Faces: Extrude, Cut and Offset
    • Faces: Flatten
    • Faces: Tilt and Facet/Smooth
    • Groups Tree
    • Groups
    • Import and Export Data
    • Layers
    • Levels and Area
    • Lines
    • Materials
    • Measure Angle
    • Measure
    • Meshes
    • Mirror
    • Model Statistics
    • Model Tree
    • Modifying Faces, Edges, and Points
    • Non-Uniform Scale
    • Offset Line
    • Orthographic Views
    • Orthographic and Perspective Camera
    • Placing Primitives
    • Place Vertex
    • Plugins
    • Polygon
    • Properties
    • Railing Along Path
    • Rectangle
    • Revit
    • Rotate Object
    • Scale Object
    • Scenes
    • Section Planes
    • Selection
    • Setting Location
    • Sun + Shadows
    • Shell
    • Snaps and Inferences
    • Solar Analysis
    • Spline
    • Storefront/Curtainwall Mullion System
    • Undo Manager
    • Visual Styles
    • Work Planes
    • World Axes
  • Plugins
    • Introduction to Plugins
    • How to Use Plugins
    • How to Develop Plugins
      • Your First Plugin
        • Plugin Playground
        • Launching the Sample Plugin
        • Adding Your Own Features
        • Saving Your Work to GitHub
        • Publishing Your Project
      • Advanced Development
        • Using an IDE
        • Cloning a Sample Plugin
        • Hosting a Plugin on a Local Server
        • Previewing a Plugin in the Plugin Manager
        • Setting Up FormIt for Development
        • Hosting a Plugin on GitHub
        • General Plugin Setup in the Manifest
        • Reloading for Local Changes
        • Client-Side vs Web-Side Engines
        • Debugging
        • Versioning
      • Additional Development Options
        • Creating an HTML Panel Plugin
        • Creating a Combined HTML Panel and Toolbar Plugin
        • Creating a Toolbar-Based Plugin
        • Testing a Combined HTML Panel and Toolbar Plugin
        • Creating an Add-In
        • Invoking Plugins and API from Dynamo
    • FormIt APIs
    • Examples
      • Generate String Lights
      • Manage Cameras Plugin
      • Properties Plus Plugin
      • 3D Context Creator
      • FormIt Plugin Community
  • Appendix
    • Keyboard Shortcuts
Powered by GitBook
On this page
  • Inside the HTML, JavaScript, and CSS Panels
  • Adding a Function to Create a Cylinder
  • Running and previewing
  • FormIt plugins API
Edit on GitHub
  1. Plugins
  2. How to Develop Plugins
  3. Your First Plugin

Adding Your Own Features

PreviousLaunching the Sample PluginNextSaving Your Work to GitHub

Last updated 3 years ago

Inside the HTML, JavaScript, and CSS Panels

When you click Edit in the Plugin Playground sample plugin, you will see the HTML, JavaScript (JS), and CSS panels. The HTML panel (left) enables you to modify the user interface of your plugin. The JS panel (middle) enables you to write functions that can communicate to FormIt using the FormIt JS Plugin API. Finally, the CSS panel (right) will determine the style of your HTML.

Adding a Function to Create a Cylinder

Let's add a feature to this plugin to create a cylinder.

First, let's configure the input field and UI button in the HTML panel. Copy the following code and paste it after line 23 and before <!-- Do not remove below scripts unless you know what you're doing- - >

This will add some basic UI elements to our plugin.

<p>Cylinder: Create a cylinder at the origin.</p>
<div>
    <input id="Radius" type=number value=2 />
    <label>Radius</label>
</div>
        
<div>
    <input id="CHeight" type=number value =0.5 />
    <label>Height</label>
</div>
        

<input id="CreateCylinderBtn" type=button value="Create Cylinder" />
        

Next, let's add two functions in our JS panel. Copy the following code and paste it at the end of the file (after line 16).

This will create a cylinder in our FormIt workspace.

// Create cylinder
const createCylinder = async (r,h) =>
{
    const posCenter = await WSM.Geom.Point3d(0,0,0);

    const histID = await FormIt.GroupEdit.GetEditingHistoryID();
    console.log(histID,posCenter,r,h);

    const cyl = await WSM.APICreateCylinder(histID,posCenter,r,h);
}


// Execute function when 'create cylinder' button is clicked
document.getElementById("CreateCylinderBtn").addEventListener("click", ()=>
{
    console.log('create cylinder clicked')

    const r = Number(document.getElementById("Radius").value);
    const h = Number(document.getElementById("CHeight").value);

    createCylinder(r,h);

});

Running and previewing

FormIt plugins API

When you’re ready to see the results, click the Play button again and you will see your updates to the plugin in the same panel.

For complete documentation on the FormIt plugins API, see the section.

useful links