Entireweb

Free Search Engine Submission

Konga Deals

Saturday, 28 March 2015

Building bridges


Last night the section of motorway closest to my home was closed from 10pm to 6am. They closed it to install a new cycle bridge intended primarily for children from one local village to cycle safely to school in another. Closing a motorway is considered quite an event around here, so a small crowd gathered to watch the proceedings in spite of the hour and the pre-spring nip in the air. Admittedly the drinks laid on by the local government – tea or wine, depending on your preferred approach for keeping warm – didn’t hurt the mood.
At around 11pm the engineer responsible from the project, Mr. Droz, addressed the gathered crowd to describe what was about to happen. The main piece being fitted was a 45m span weighing 40 metric tons (the overall bridge will end up being 100 tons). For this 45m span the tolerance was 5-10mm. The bridge would be anchored on the south side and they expected the steelwork to vary in total length by 3-4cm between the coldest winter and the hottest summer. Many of the design options related to the bridge had been chosen with a view to allowing the bridge to be put in place in a single night, minimising the impact on the motorway beneath it.
I chatted a bit later with Mr. Droz afterwards, asking him (and I always feel a bit strange asking this question – I don’t want to sound like I’m selling something) what software had been used on the project. I was relieved when he said “AutoCAD, of course!” and then – after I’d mentioned working for Autodesk – went on to extoll the virtues of the product, also describing how they’d modelled the bridge fully in 3D.
We stood there watching the bridge lift into the air. I could tell Mr. Droz was getting quite emotional – it was the culmination of 4 years of his hard work – and we reflected on how satisfying it was to have contributed in some (in my case very small) way to the creation of something that will be used by future generations.Our new cycle bridge

Docking a WPF window inside AutoCAD – Part 3


In this post we’re wrapping up this mini-series on docking, which is part of a much broader story arc around a “command-line helper” tool, of course. But then we’re reaching the end of that, too, I suspect, as the app’s just about done. Hopefully it’s ready for posting to Autodesk Labs, at least.
Last time we added right-click dragging to allow our keywords window to be moved around without interrupting the active command. Now we’re taking it a step further to preview docking at one of the four corners of the drawing window, as well as to actually dock the dialog when the right mouse-button gets released, of course.
Here’s a recording of this in action:

CmdLineHelper with draggable docking
And here’s the “completed” project (we’ll see what changes need to be made once we start to get feedback from users).
One really interesting problem took some debugging: we’re storing a dictionary of docking locations and their corresponding enumeration values so we can check on each “mouse move” to see whether the cursor is near enough to one of the locations to preview it. Because this list’s contents will change with the size or position of the screen, we recreate it each time a drag operation begins. Very curiously, calling Clear() on this dictionary from CommandEnded() (we have a StopDragging() helper that gets called from there, just in case “on right mouse-button up” doesn’t get called) resulted in our “unknown command” event handler not firing! I’m used to the need to be careful about drawing modifications from CommandEnded() – these can kill your undo file, for instance – but this was a completely non-AutoCAD-centric data structure. Setting it to null rather than clearing it causes the code to work properly, but this was a really interesting (and obscure) bug that I thought it was worth mentioning. Please post a comment if you’ve experienced something similar and have an idea about what’s going on.
It took a little work to add the docking preview, itself: I used a new, transparent WPF Window – sized at exactly the drawing area – to which we add a Canvas containing a Rectangle. The Window gets resized whenever a drag operation starts (in case the outer window has changed size) and whenever we find the mouse is close enough to one of our dock locations we set the rectangle to the right size & location. I ended up choosing a standard gray – matching the colour used for the command-line docking – but that’s a simple detail to change if you need to make your own docking preview more visible.
All in all it works well: the ability to move the dialog around during a command – docking, as needed – does make the app much more usable. Hopefully you’ll also find this useful for your own “dockable” windows inside AutoCAD.

Docking a WPF window inside AutoCAD – Part 2


I’m happy to say that the implementation I mentioned in the last post ended up being pretty straightforward. Which is actually great, as I have some important posts to work on for next week. :-)
Today we’re going to take a look at the next stage of the “command-line helper” implementation: basic right-click movement of the global keywords dialog, so we can set a custom location for the dialog without needing to use the KWSDOCK command.
Here’s the code in action:

CmdLineHelper with right-click dialog move
The main work for this stage was to add support for right-click, mouse move and right mouse-button up events, making sure that the dialog is displaced accurately irrespective of where the mouse gets moved. And that’s actually a really nice feature of this version: you can move the dialog off the main AutoCAD window, if you want to (this wasn’t supported in the KWSDOCK command as we’re using Editor.GetPoint() to let the user select custom locations).

Docking a WPF window inside AutoCAD – Part 1


During the course of this week we’re going to look at extending the command-line helper sample posted last week by allowing our global keywords window to “dock” to the four corners of the drawing window as well as to remain fixed at a custom location somewhere on the screen. I use the term “dock” here loosely, as we’re really just placing it in one of the corners of the drawing window. If we wanted a modeless dialog that was properly docked into AutoCAD then we’d almost certainly want to use a PaletteSet.
Here’s a quick video demonstrating the KWSDOCK command, which allows the user to select one of the four corners or a custom location:

CmdLineHelper with docking
While the changes aren’t very extensive, it doesn’t make sense to embed the complete code in this post. Here’s a link to the updated C# project for you to look at in depth.

AutoCAD 2016


It’s that time again! Over the coming days you’re going to be hearing lots about the next release of AutoCAD, codenamed “Maestro”.AutoCAD 2016 makes a splash
Before taking a look at AutoCAD 2016 from a developer’s perspective – which we’ll do next time – in this post we’re going to take a quick look at its user features.

AutoCAD 2016 for developers


After our quick look at AutoCAD 2016 from a user perspective, let’s now spend some time looking at the things important to developers in this latest release.

Compatibility
Off the bat it’s worth stating that AutoCAD 2016 is a DWG compatible release: it’s using the same file format as AutoCAD 2013, 2014 and 2015. It’s also a binary application compatible release: ObjectARX apps written for AutoCAD 2015 should work in 2016 and it’s likely that .NET apps built for AutoCAD 2014 will work, too. That said, some changes have been made to the security model for this release of AutoCAD, so you may want to make sure these changes haven’t impacted your application…

Security
You’ll see straight away when you try to load your application that there’s a bit more going on in the 2016 version of this dialog.
Security dialog in AutoCAD 2016

AutoCAD 2016: Calling commands from AutoCAD events using .NET


It’s time to start looking in more detail at some of the new API capabilities in AutoCAD 2016. To give you a sense of what to expect in terms of a timeline, this week we’ll look at a couple of uses for DocumentCollection.ExecuteInCommandContextAsync() and next week we’ll look at point cloud floorplan extraction and (hopefully) security and signing. The first use of ExecuteInCommandContextAsync() I wanted to highlight was one raised in a blog comment a couple of months ago. The idea is simple enough: we want to be able to launch a command reliably from an event handler, in our case the Click event of a ContextMenuExtension’s MenuItem. Before now you would have to use Document.SendStringToExecute(), as we saw in this previous post – calling a command in another way would typically lead to an eInvalidInput exception.
There are certainly advantages to avoiding SendStringToExecute() in this scenario: while commands that use the pickfirst selection set are OK – including ones you implement yourself – using Command() or CommandAsync() gives you greater control over which entities you choose to pass entities to the command being called (whether it accepts pickfirst selection or not).
By the way, as mentioned briefly in a comment on the last post, in AutoCAD 2015 you will find the DocumentCollection.BeginExecuteInCommandContext() method, which was the former name for ExecuteInCommandContextAsync() (it’s taken from the ObjectARX method it calls through to). If you try to make the below code work in AutoCAD 2015 with the previous method name, you’re probably going to hit this error: ‘Unknown command: “EXECUTEFUNCTION”’.
Before we look at the code, here’s a recording of what we want it to do:

Context menu to scale by 5
It’s pretty simple in concept, at least. Here’s the C# code that makes it work:

AutoCAD 2016: Calling commands from AutoCAD events using .NET

It’s time to start looking in more detail at some of the new API capabilities in AutoCAD 2016. To give you a sense of what to expect in terms of a timeline, this week we’ll look at a couple of uses for DocumentCollection.ExecuteInCommandContextAsync() and next week we’ll look at point cloud floorplan extraction and (hopefully) security and signing.
The first use of ExecuteInCommandContextAsync() I wanted to highlight was one raised in a blog comment a couple of months ago. The idea is simple enough: we want to be able to launch a command reliably from an event handler, in our case the Click event of a ContextMenuExtension’s MenuItem. Before now you would have to use Document.SendStringToExecute(), as we saw in this previous post – calling a command in another way would typically lead to an eInvalidInput exception.
There are certainly advantages to avoiding SendStringToExecute() in this scenario: while commands that use the pickfirst selection set are OK – including ones you implement yourself – using Command() or CommandAsync() gives you greater control over which entities you choose to pass entities to the command being called (whether it accepts pickfirst selection or not).
By the way, as mentioned briefly in a comment on the last post, in AutoCAD 2015 you will find the DocumentCollection.BeginExecuteInCommandContext() method, which was the former name for ExecuteInCommandContextAsync() (it’s taken from the ObjectARX method it calls through to). If you try to make the below code work in AutoCAD 2015 with the previous method name, you’re probably going to hit this error: ‘Unknown command: “EXECUTEFUNCTION”’.
Before we look at the code, here’s a recording of what we want it to do:

Context menu to scale by 5
It’s pretty simple in concept, at least. Here’s the C# code that makes it work:
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.EditorInput;
using Autodesk.AutoCAD.Geometry;
using Autodesk.AutoCAD.Runtime;
using Autodesk.AutoCAD.Windows;
using System;

namespace ContextMenuApplication
{
  public class Commands : IExtensionApplication
  {
    public void Initialize()
    {
      ScaleMenu.Attach();
    }
    public void Terminate()
    {
      ScaleMenu.Detach();
    }
  }

  public class ScaleMenu
  {
    private static ContextMenuExtension cme;

    public static void Attach()
    {
      if (cme == null)
      {
        cme = new ContextMenuExtension();
        MenuItem mi = new MenuItem("Scale by 5");
        mi.Click += new EventHandler(OnScale);
        cme.MenuItems.Add(mi);
      }
      RXClass rxc = Entity.GetClass(typeof(Entity));
      Application.AddObjectContextMenuExtension(rxc, cme);
    }

    public static void Detach()
    {
      RXClass rxc = Entity.GetClass(typeof(Entity));
      Application.RemoveObjectContextMenuExtension(rxc, cme);
    }

    private static async void OnScale(Object o, EventArgs e)
    {
      var dm = Application.DocumentManager;
      var doc = dm.MdiActiveDocument;
      var ed = doc.Editor;

      // Get the selected objects

      var psr = ed.GetSelection();
      if (psr.Status != PromptStatus.OK)
        return;

      try
      {
        // Ask AutoCAD to execute our command in the right context

        await dm.ExecuteInCommandContextAsync(
          async (obj) =>
          {
            // Scale the selected objects by 5 relative to 0,0,0

            await ed.CommandAsync(
              "._scale", psr.Value, "", Point3d.Origin, 5
            );
          },
          null
        );
      }
      catch (System.Exception ex)
      {
        ed.WriteMessage("\nException: {0}\n", ex.Message);
      }
    }
  }
}
We might have used Editor.Command() rather than Editor.CommandAsync(), but ExecuteInCommandContextAsync() is expecting an asynchronous task to be passed in, so doing so would lead to a warning about the async lambda running synchronously. Ultimately it works comparably, but the above code makes the C# compiler happier, so I’ve left it that way. I’ve also chosen to await the call to ExecuteInCommandContextAsync(), although for this type of operation it’s probably not strictly needed.
In the next post we’re going to take a look at calling AutoCAD commands based on external events: we’re going to hook up a FileSystemWatcher to check for changes to a folder and call a command inside AutoCAD each time a file gets created there.

NuGet packages now available for AutoCAD 2016


Some time ago we posted the NuGet packages for AutoCAD 2015’s .NET API. The packages for AutoCAD 2016 are now live, too.
Here’s the report from the NuGet console (accessible in Visual Studio via Tools –> NuGet Package Manager –> Package Manager Console).
PM> Get-Package -filter AutoCAD.NET -ListAvailable

Id                   Version    Description/Release Notes
--                   -------    -------------------------
AutoCAD.NET          20.1.0     AutoCAD 2016 API
AutoCAD.NET.Core     20.1.0     AutoCAD 2016 core object model API
AutoCAD.NET.Model    20.1.0     AutoCAD 2016 drawing object model API
To install the 2016 versions of the assemblies into your project, you can use the following command, once again in the NuGet Console.
PM> Install-Package AutoCAD.NET -Version 20.1
And the 2015 are still available too, of course:
PM> Install-Package AutoCAD.NET -Version 20.0
I actually just learned a nice trick: you can use tab to autocomplete the version number inside the NuGet console, as you can see below. Very handy!

NuGet package manager console with autocomplete

Wednesday, 25 March 2015

Here is AutoCAD 2016; the last perpetual license you will ever get.

Introducing AutoCAD 2016! The latest! The greatest! The last perpetual license of AutoCAD you or anyone else will ever purchase! If there were ever a time to upgrade your AutoCAD license it is now! So what's new? Well there really isn't any one new thing but instead there are a lot of updates to many existing commands. One thing that isn't new is the DWG file type. Yep AutoCAD 2016 will still run on AutoCAD 2013 DWG. Autodesk has also removed the ability to password protect DWG files. It can open and use password protected files but it will not be able to create them. This update brings performance improvements, new ways to create dimensions, a few UI tweaks, a new osnap, additional point cloud tools, updated referencing options, a brand new 3D rendering engine, and a handy system variable monitoring tool.




User Interface Enhancements

AutoCAD 2016 has added new functionality to many user interface elements. There are some name changes, new system variables, and additional options to already existing tools. There are also new controls for older commands.

The New Tab file tab has been renamed to Start. The system variables that control it have also been updated. The NEWTABMODE system variable is now STARTMODE but it essentially works the same way. When it is set to 0 the Start tab will not be displayed. Set to 1 and it will be displayed. There are controls in the 2016 deployment creation tools that will allow this variable to be set to either on or off.

Figure 1: The Start Tab will remain when creating or opening files.

Create stylish leaders with a multileader style

autocad_tips_multileader-style-1If you use leaders, you should consider creating a style. Once you save the style, you can use it whenever you need a leader.
Here are the steps to create a multileader style:
  1. Go to Home tab, Annotation panel and click the down arrow to expand the panel.  Click the Multileader Style icon to open the Multileader Style Manager dialog box.

3D tutorial: Draw a fancy square glass bottle cap in AutoCAD

autocad-tips-tutorial-square-bottle-cap-5parvez-mahmoodThis is a guest blog post by Parvez Mahmood, General Manager, Engineering Systems/ER Solutions in Islamabad, Pakistan. He has been teaching AutoCAD for last 10 years to industrial and university students.
It’s a tutorial that will show you how to draw a fancy square glass bottle cap in AutoCAD. It’s a great tutorial to work through if you want to advance your 3D skills.
On the right, you can see what the final bottle cap will look like, with perhaps slight differences in proportion, depending on the values you use.

Customize how the multi-functional grip menu works

Multi-functional grips have been around since AutoCAD 2012 and they give you a menu of options when you hover over a grip or right-click a selected grip. Here you see the multi-functional grip menu for one of the vertices on a polyline.
By default, you can also repeatedly press the Ctrl key to cycle between the options on the menu. For example, in the figure you see here, if you select the grip that’s highlighted and press Ctrl twice, you’re up to the Remove Vertex option.  You see a prompt to pick to remove the vertex.
autocad-tips-customize-multi-functional-grips-1
I find this Ctrl method pretty confusing. Since you don’t see the options, so you don’t really know

Track the time you spend on a drawing


autoacad-tips-time-commandWhether you need to bill your clients the time your work on a drawing or just want to know how efficient you are (maybe your boss wants to know), you can do it in AutoCAD. You do this with the TIME command, which automatically tracks the time you work on a drawing.

Guest Post: Draw a circle with radius tangent to two objects

Today’s post is from Jason Bewerk. Jason is a blogger and CAD-enthusiast. He works full-time at a design firm and enjoys helping others with CAD and thus started 12CAD.com to provide detailed tutorials and exercises for everybody to use.

In the exercise below, you don’t draw the entire figure, but just focus on creating the circles that would be the basis for the figures perimeter.
We have the image below to replicate, and luckily we are given all dimensions, which will make the task simpler. Today’s difficulty is simply to learn how to draw a circle with specified radius tangent to two objects. As you can see from the figure below, we need to be able to create the R180 circle and R75 circle.
hatchautocad
The line AB in the figure below forms an angle of 30 degrees with the horizontal. To draw this line, follow these steps:

How to use Toggle Button Ribbon API

Tuesday, 24 March 2015

Introducing...AutoCAD 2016 (Part One)


AutoCAD 2016 is locked and loaded - coming soon to a reseller near you!  Here is an early look at some of the key features in the next (Awesome) release of AutoCAD! Updated (and far better) Revision Clouds
Gone are the wonky (yes wonky) Revision Clouds of the past.  Have you ever tried editing one of them?  Now it's easier than ever to create rectangular, polygonal, freehand or object revision clouds.  The grips make more sense and are based on the shape of the revcloud.  Those grips make it just that much easier to make changes to your revision clouds after the fact.
Revcloud
There's even a cool Modify option that lets you draw another revision cloud and erase selected portions of existing ones!

AutoCAD 2016 (Part Deux)

AutoCAD 2016 - Part Tres

Label the scale of individual viewports

A reader asked me how to label the scale of individual viewports when they have different scales. You can use fields to accomplish this. Here’s a drawing with 2 viewports, one on the left and one on the right. Each one uses a different scale.
autocad-tips-label-scale-viewports-1
Here are the steps to label each viewport:

Saturday, 21 March 2015

The new AutoCAD 2015 is here so why is it the best release ever?



Enhancements Help Customers Connect Workflows Across Integrated Desktop, Cloud, and Mobile Solutions

Ahhhh, spring is in the air. Its warmer outside, the birds are chirping, the sun is rising before I go to work, and Autodesk is announcing the new line of software releases. As per usual, the first major announcement is with AutoCAD. The focus of this release is to “Boost productivity“, with the new features falling into one of four categories: User Interaction, Document, Design, or Connect. Look for AutoCAD to “Jumpstart design workflows“, “deliver a richer visual experience“, and “bring the real world into the AutoCAD canvas”

Monday, 16 March 2015

AutoCAD 2015: Cursor badges...


The cursor is enhanced in AutoCAD 2015 to provide contextual feedback. It includes badges to reflect the state of many common operations.
Selection badges indicate when you are creating crossing or window selections.

How to create partial cuix that appends Panel to "Add-ins" tab.


Here is a sample code to create a partial cuix at runtime. It creates a ribbon panel with a command button. After the cuix is loaded in AutoCAD using cuiload, the panel should appear in the "Add-ins" tab.