Archive | Plugins RSS feed for this section

Elevation Along a Path

20 Feb

In my last post, I showed you how to get the elevation at any point in Albuquerque. In this post, we are going to improve the application and get an elevation profile of the City. I have put the code on JsBin for you to play with and test out.

The Application

The application will allow the user to draw a line and will then draw a chart showing the elevation at the endpoints of each line segment. The results will look like the image below. ElevationLine In the image above, you will see the green line I have drawn and a chart above the map. The chart shows the elevation profile. Notice how the elevation dips at the river and rises significantly as we approach the Sandia Mountains.

Required Plugins

To make the application work, you will need to use the Leaflet.Draw plugin. This is what lets the user draw the line. We only want the user to draw a line, so I will modify the sample config code on github to:

var drawnItems = new L.FeatureGroup(); map.addLayer(drawnItems); var drawControl = new L.Control.Draw({ draw: { marker: false, position: ‘topleft’, polygon: false, polyline: { metric: false, shapeOptions:{color:’green’,opacity:1} }, circle:false, rectangle: false }, edit: { featureGroup: drawnItems, edit: false } }); map.addControl(drawControl); map.on(‘draw:created’, function (e) { var type = e.layerType, layer = e.layer; if (type === ‘polyline’) { CODE GOES HERE } drawnItems.addLayer(layer);

This will only give the option for drawing a line. We will add our code in the if statement that equals polyline. You will also need to reference Charts.js. I really like Charts.js for static charts and Smoothie charts for streaming data.

The Completed Logic

We are going to allow the user to draw a line. When they are done, we need the points for each segment. Once we have the points, we will buffer them and get the elevation just as we did in the last post.

drawLine=layer.getLatLngs(); for(var x=0;x<drawLine.length;x++){ a=L.marker([drawLine[x].lat,drawLine[x].lng]); var b=a.toGeoJSON(); var buffered = turf.buffer(b,0.01,”miles”); var result = turf.featurecollection(buffered.features.concat(b)); var g='{“rings”:’+JSON.stringify(buffered.features[0].geometry.coordinates)+’}’; howhigh(g); }

We calla function howhigh(g) and pass the geometry. This function is the AJAX call.

var d=JSON.parse(http.responseText); points.push(d.features[0].attributes.ELEV); l.push(label); label=label+1; drawChart();

The AJAX call pushes the elevation to an array and increments the label variable. It then calls drawChart(). We will update the chart as each result comes in from the AJAX calls.

function drawChart(){ data={ labels: l, datasets: [ { label: “$”, fillColor: “rgba(151,187,205,0.5)”, strokeColor: “rgba(151,187,205,0.8)”, highlightFill: “rgba(151,187,205,0.75)”, highlightStroke: “rgba(151,187,205,1)”, data: points }]}; var ctx = document.getElementById(“data”).getContext(“2d”); myBarChart = new Chart(ctx).Bar(data, {scaleShowGridLines : true,responsive:false,showTooltips:false,scaleBeginAtZero : false,barValueSpacing : .5}); }

The function configures the data and labels and adds the chart to the canvas.

To Do

The application only allows you to draw a single line. In the future, the application needs a reset function to clear the data and chart and allow the user to draw a new line.


Agent Based modeling in ArcGIS with Agent Analyst (RePast)

12 Oct

I love agent based modeling. I have tried to write agents by hand in classes and then use them to call arcpy to get data. Not a smart or efficient way to go about things. Why reinvent the wheel when there are already some great libraries that handle a lot of the work for you. I want my model to integrate with GIS – because I have tons of data already in GIS and because I need a graphical representation of the model and I do not want to program it by hand.

Agent Analyst is the solution.

There is  even a free book with exercises and data. Simple to install and the book is excellent. I skipped ahead a little for my first model and made agents move randomly, write the agent out and refresh the display.  The example will make more sense if you read the book. Here is my code:

In the Agent, the step() function calls self.move()

def move():


The agents just move in a random direction.

In the Model you need the following functions:

def updateDisplay():

def writeAgents():

Then in the Environment, you must schedule the writeAgents() then the updateDisplay() functions.

Not the most detailed post, but I have just started playing and wanted to let you know this tool is out there.

MongoDB in QGIS

28 Dec
Displaying my MongoDB Data

Displaying my MongoDB Data

I recently installed the MongoDB Plugin for QGIS. The plugin allows you to connect to a MongoDB and load your data. I stored point data – long and lat – for all the public art in Albuquerque. Using the plugin, I connected to my MongoDB and loaded them.

I had trouble getting the plugin to install. My fix was to install pymongo and BSON to my local Python2.7 then copy it from the site-libs to the QGIS directory (C:\Program Files\Quantum GIS Lisboa\apps\Python27\Lib\site-packages). then I had to turn on the plugin under manage plugins.

This did the trick. Then I fired up my mongod, loaded QGIS and connected using the defaults. It prompted me for a Database and then a Collection. Looks like it requires a GEO2D. You can see my data in the image above.

Can’t wait to start playing….

3D PDF Converter for Revit

9 Jul

In 2010, I wrote a blog post on using Adobe Acrobat 9 Extended to create 3D PDFs from a Revit model by exporting it to IFC. In 2011, I published the article in AugiWorld. Shortly after the article was published, the 3D PDF world changed. Adobe released Acrobat X and dropped support for every file type except U3D and PRC. Revit doesn’t export to U3D or PRC, so now what?.

Well 3DA Systems has released a Revit plugin – PDF Converter for Revit – that runs in 2012 and 2013 and allows you to create a full page 3D PDF with the click of a button, or export a PRC and using Acrobat X, insert the model into your document.

I received a trial of PDF Converter for Revit and tested it out.

I wrote down two criteria that the PDF Converter needed to meet:

  1. It had to allow me to import the model in to a PDF that I designed, and
  2. It had to export the model data.

No data in the PDF defeats the purpose of a 3D Revit model, and by not allowing me to design where the model is placed in the PDF, it inhibits my uses of the model. I want to create cut sheets and marketing materials. So, my model must import in to these documents.

The 3D PDF Converter met both of these criteria. It did everything that I could do with Adobe 9 Extended, but it also added an add-in toolbar in Revit which allowed for the quick creation of a full page 3D model with a single click.

The plugin installs with a Windows executable and took less than a minute. After launching Revit, the add-in is now available.


3DA Systems Add-In

The add-in has three options:

  1. Help – which you should not need.
  2. Create PDF – will create a full page PDF of the {3D} view.
  3. Create PRC – which will create a PRC that can be imported in to Adobe.

I almost always prefer creating a PRC; however, I can see times when I just need to send a model and the page design is irrelevant. For those times, the create PDF button is all you need.

After creating the {3D} View, select Create PDF. You will be prompted to save the file. Select a location and name and save the file. Then you will be able to select the export options and finalize the 3D PDF.


General Settings. Make sure “METADATA not Included” is unchecked.

When to enable and disable the content

How to Display 3D Content. I check Open Model Tree.

The single most important box to UNCHECK is “Metadata Not Included” in the General Settings Tab. If you check this box, you will lose all of the information and properties associated with your model components. When you click on a wall, it will be highlighted in the model tree, but the data – height, length, material… – will not appear.

That is all you need to do to create a full page 3D PDF: click Create PDF, edit the settings, and done!

To embed your Revit model in to a PDF which has already been created, export the {3D} View to PRC. When you click “Create PRC” you will get the same options window, but only the General tab is available.

Here is my designed PDF that will hold my model.


Open the PDF in Acrobat X. On the top right menu you can select “TOOLS” and a toolbar will be placed on the right side of the window.

Select “Multimedia” and then “3D.” Your cursor will turn to cross-hairs and you can draw a box where you want the model to go.

You will be asked to select the file. Choose the PRC that you exported from Revit.

That is it. You now have a 3D PDF of your Revit model.

My PDF with the Model

You can share this model and anyone with the free Adobe Acrobat Reader will be able to view the model, cut sections, measure, and see the object properties. As with any PDF, you can lock it down. I added a password to my PDF in the document properties to open the file and to print.

Download MyPDF. The password to open it is “bim.”

There are so many things you can do with a 3D PDF. You can use it for project information sheets, for construction administration, to create an archive of projects, send them to clients and consultants, or use them in marketing materials.

3D PDFs were, and still are, an under appreciated technology. 3D PDFs compress models to a size that is beyond belief – the 6.7M sample file is only 384kb as a PDF.

The 3D PDF Converter for Revit makes creating 3D PDFs simple. As a private consultant, I do not have a huge budget for additional add-ins, but the plug-in is affordable. Currently you can get it for $99, but even full price it is only $150. My examples were done in Revit Architecture, but the plug-in also works with Revit MEP and Structure.

Here are some PDF samples of 3D models made with 3D PDF Converter for Revit.



Modify Revit Model Data Through the Web

10 Jan

In my post on Programming for Architects I mention how I can use PHP to edit Revit model data.  In this post, I will briefly explain how this is done and point you to a very simple website demonstrating the results.

1) Export your Revit model to a datababse using RevitDBLink. If you don’t care about bringing the results back in you can export a single schedule to CSV and create a database table from that, or export the whole model any way you wish.

2) Download a WAMP stack. WAMP stands for Windows, Apache, MySQL and PHP. You can get the entire stack here:  WAMP Server.

3) Create a webpage in the WWW directory that has a form and whatever else you want to display. The form should call a PHP file. Mine calls insert.php to change the values and a popup.php file to display data. Name the HTML file index.html.

4) Create a PHP file that updates the database.  This is where you need to be able to code, or at least copy and modify code from the web.

5) Start Apache and browse to http://localhost/           to see it in action.

I have a very simple example running on my website. Click on a room to see the current properties. Change the values and click submit. Reclick on a room to see the changes. Currently, this edits the database in real time but requires a user to open Revit and bring the database back in. I see this as a good thing because it adds a layer of protection. It allows the user to import a specific table (rooms) and preview the changes prior to importing.

Happy Hacking.

RevitDB: Edit your model in Excel

22 Mar

In an earlier post, I showed how to edit a Revit model from MS Access. In this post, I will show how to edit your model using Excel.

Here is the model.

The model is exported to an Access database using the RevitDB Link plugin. For more information on how this is done, see my earlier post. Once the database is created, import an Excel sheet and link it to an external sheet. In this example, I have a link called ‘WallsFromExcel’ to an external sheet called ‘Walls-Excel.’

When the ‘Walls-Excel’ spreadsheet is modified, it is automatically updated in the database because of the direct link.

Add a Query to the database that updates the Walls table from Revit with the spreadsheet. Run the query….

……and update the Revit model with DB Link.

DWF in a Website

7 Jan

Embedding a DWF in to a website. Autodesk has a Firefox plugin for their Design Review software.  To make a DWF work in Internet Explorer as well, try out Autodesk Freewheel.  Get the plugin <a href=″> here</a>.  Add this code to your site to embed a DWF:

<OBJECT ID=”ADR” TYPE=”application/x-Autodesk-DWF” WIDTH=”900″ HEIGHT=”500″>
<PARAM NAME=”dwffilename” VALUE=”http://WhereYouPutYourFile/FileName.dwf”/&gt;

Its that easy.

I am testing my own sites now in both 2D and 3D using the DWF I have uploaded here.