# Quality control AutoCAD drawings in Grasshopper
Software used: AutoCAD, Rhino, Grasshopper
Quality control your AutoCAD drawings with the visual programming power of Grasshopper!
In this tutorial, we'll send a floorplan from AutoCAD to Rhino with Speckle, run a simple Grasshopper script to find incorrectly drawn lines, and send the annotations back to AutoCAD. We'll also adjust some blocks in Rhino along the way.
Before getting started, make sure you have the Speckle Manager installed and an active account set up on a Speckle server. This tutorial uses AutoCAD 2021 and Rhino 7 - check that you have the Speckle 2.0 connectors installed for these applications.
- Open the AutoCAD file. The drawing is a simplified version of a sample dwg that comes installed with AutoCAD.
- Pull up the AutoCAD Desktop UI by typing
Specklein the command line, or by clicking on the Speckle 2 plugin in the Add-Ins tab in your ribbon.
- Open a new Rhino file and start Grasshopper by typing
Grasshopperin the command line. Open the .gh file included with this tutorial.
# Send the AutoCAD Drawing to Rhino
Let's send our first stream to Speckle! Keep in mind that we'll use branches to organize our data in this tutorial.
- Create a new
Plan Coordinationstream and check that it's on Sender mode. If not, click the arrows on the top right corner to toggle between the two modes.
- Create a new
Annotationsbranch by clicking on main in the bottom left of the stream and selecting Add a new branch from the drop-down. Switch back to main after creating the new branch.
- Select all geometry in the file.
- Click the blue Objects button and select Set Selection from the dropdown.
- Click Send on the
Plan Coordinationstream. Type
Drawing for reviewin the comment line, and click Send again to commit the selected geometry.
- To view the drawing in the Speckle Web App, click the Open in browser icon in the top right corner of the stream. Keep this tab open for later.
- In Rhino Desktop UI, click the blue Add a stream button on the bottom. Add the
Plan Coordinationstream card to UI by clicking the arrow next to the stream in the popup window.
- Click the big Receive on button the stream and watch the drawing you just sent come into Rhino!
# Run a Grasshopper Script to Identify Bad Lines
The sample plan drawing from AutoCAD has some messy lines with gaps or overlaps at the ends that need to be cleaned up. Now, we'll run a quick analysis in Grasshopper and send the results back to AutoCAD.
- Select all drawing lines in Rhino and set them in the input
Crv nodein Grasshopper by right-clicking the node and selecting Select Multiple Curves from the dropdown.
- You should see small circles previewed on all curve ends that are not correctly adjoining other curves in the drawing! Adjust the
Radiusslider in the input to customize the size of these annotation circles.
- To send our annotations back to AutoCAD, get the
Annotationsbranch URL from the Speckle Web App tab we opened in the previous section. Navigate to the
Annotationsbranch page in the browser and copy this URL.
- In the Speckle section of the Grasshopper script, paste your copied URL into the text panel.
- Make sure you have a valid account selected for the stream server in the accounts node, and click Send in the Send Data node.
- Go back to AutoCAD and swap the
Plan Coordinationstream to receiver mode. Select the
Annotationsbranch from the branch dropdown, and click Receive.
- The Grasshopper generated circles now appear in your file - change their layer color to red and use these as a guide to see which lines need to be fixed!
# Modify Drawing Blocks in Rhino
Finally, we'll make some changes to the door blocks and send them back to AutoCAD.
- Double-click a door block instance in the Rhino file to open block editing mode.
- Trim the end of the door swing curve to match the end of the door curve, and press enter to save block changes. Make the same change for any other door block definitions that need trimming.
- Open the Block Manager by typing
BlockManagerin the command line. Locate the door block definitions (left and right swing) and rename them by removing the stream commit prefix. Now they are ready for sending!
- Create a new
Block editsbranch in the
Plan Coordinationstream in Rhino.
- Select all door block instances, set the selection, and send them to this branch.
- Receive the new blocks in AutoCAD - open Block Manager to delete the old door blocks from your file, and rename the received block definitions by removing the commit prefix.
Block conversions in Rhino and AutoCAD are an early prototype, so we currently do not support nested block definitions or dynamic blocks. If you have feedback on this feature, hop over to our community forum (opens new window) and give us a shout!