November 30, 2014

ACA: AEC Modify Tools, Part 4, AEC Subtract

First post in series [AecLineworkExtend].
Previous post in series [AECLineworkDivide].

The AecLineworkSubtract command is available on the Home ribbon tab, on the Modify panel flyout, by selecting the Subtract tool from the Merge/Subtract flyout. If the Subtract tool is not the displayed tool on the Merge/Subtract flyout, select the right side of the split button (down arrow icon) to deploy the flyout and choose the Subtract tool. Or, with no command active, you can right click in the drawing window, and choose AEC Modify Tools > Subtract from the context menu.

The AecLineworkSubtract command can be used to subtract (delete) parts of linework, AEC Polygons, Mass Element Extrusions that have an embedded profile, Spaces and Hatches as well as from Block References which contain any of these objects. There are two options for specifying the extents of the subtraction area:
  • Select one or more items in the drawing, which form at least one closed loop. Any single closed item will work (closed Polyline, Circle, Ellipse, AEC Polygon, Mass Element or Space), as will any combination of objects that, combined, form at least one closed loop.
  • Press the ENTER key when prompted to select items to subtract, and then define a subtraction rectangle by selecting opposite corners of a rectangle. The rectangle will have sides parallel to the X- and Y-axes of the current UCS.
If you select objects to specify the subtract border, you will asked if you want to erase the selected items. The default response is No. The Screencast embedded below shows the AecLineworkSubtract command in use on various object types. As with the AecLineworkTrim and AecLineworkDivide commands, if the original object was a closed object, a closed obejct will result, with Circles becoming closed Polylines.
Here are some additional notes regarding the AecLineworkSubtract command:
  • MText, Text, Ellipses and Ellipse Arcs cannot be added to the selection set of objects from which to subtract a portion.
  • Ellipses and Ellipse Arcs can be selected as (part of) a boundary defining the area to subtract.
  • Mass Elements with a shape other than "Extrusion" and Mass Element Extrusions that have an external Profile can be selected as objects from which to subtract, but will not affected by the AecLineworkSubtract command. These types of Mass Elements can be used to define the area to subtract.
  • If a Block Reference is selected as an object from which to subtract, only those nested objects within the block on which the AecLineworkSubtract command works will be affected.
  • Attributes within a Block Reference will not be affected by the AecLineworkSubtract command.
  • If a Block Reference is selected as an object from which to subtract, it has subtractable nested elements and it is the only instance of that Block Reference in the drawing, then the original block definition will be redefined to include the effects of the subtraction. If at least one instance of the Block Reference remains unaffected by the subtraction, then the original block definition will remain unchanged and the affected instance(s) will become instance(s) of new, anonymous block definition(s).
  • Multi-View Blocks can be selected as an object to have a part subtracted, but will not be affected by the command.
  • If the area to subtract effectively splits an object into two or more separate pieces, the result depends upon the selected object. Closed Polylines and Circles will result in two (or more) separate Closed Polylines. Hatches, Mass Element Extrusions (embedded Profiles), AEC Polygons and Spaces will result in one object, with two (or more) separate, non-contiguous regions.
  • Associative Spaces, Walls, Doors, Windows and Door/Window Assemblies can be selected as items from which to subtract, but will not be affected by the command. Non-associative Spaces do work with the AecLineworkSubtract command.
  • Subtracting from an associative Hatch will result in a non-associative Hatch, regardless of whether or not the boundary of the Hatch is included in the subtraction.
  • If an object in the subtract selection set is entirely within the subtraction boundary, it will be deleted.

As with the AecLineworkDivide command, there are object types and combinations of objects within a Block Reference that I did not test. If you are thinking of using the AecLineworkSubtract command in a situation that you have not done so previously, you may want to use the Mark option of the UNDO command to place one or more UNDO Marks prior to using the command, so that you can easily UNDO Back to the point before the command was used if you get unexpected results.

Next post in series [AECLineworkObscure].

November 23, 2014

ACA 2015: Cannot invoke (command) from *error* without...

Several people in the Autodesk AutoCAD® Architecture General Discussion Group have experienced problems when trying to run AutoLISP routines in which an error condition is encountered. Instead of the usual, often helpful, error message at the Command: line, this error shows up, instead:
Cannot invoke (command) from *error* without prior call to (*push-error-using-command*).

This appears to happen even when the first thing you do in a drawing is evaluate a LISP expression with an error, for example, by typing (alert 1) at the Command: prompt and then pressing ENTER.

If you were hoping for a more informative error message, so you could try to work out what went wrong, you will want to reset the initial definition of the *error* function to what it should be:
(defun *error* (msg) (princ "error: ") (princ msg) (princ))

One way to get this code loaded into every drawing you open would be to include it in your ACADDOC.lsp file (if you have one; if not, you can create one). This file needs to be somewhere in the AutoCAD Search path (and be the first on of that name found); if your firm has a standard ACADDOC.lsp file and you do not have rights to edit it, you may want to discuss having this code added to it with your CAD Manager. You will also want to have the folder in which the ACADDOC.lsp is placed be designated as a Trusted Path (Files tab of Options dialog) if you have SECURELOAD set to 1 to avoid the nag dialog about loading it. If SECURELOAD is set to 2, you have to have the ACADDOC.lsp file in a Trusted Path folder, or the file will not load at all.

There are other ways to get this code loaded with each file, if using ACADDOC.lsp does not work for your situation. The easiest would be to open Notepad and paste the code above into it, then save the file with a name of your choosing and a LSP extension, again, to a folder that has been designated as a Trusted Path. Then add that file to your Startup Suite in the Load/Unload Applications dialog (APPLOAD command).

I am not sure why the *error* function is not properly initialized, but running the above code when opening a drawing or creating a new drawing will resolve this issue and give you the expected error messages.

November 09, 2014

ACA: AEC Modify Tools, Part 3, AEC Divide

First post in series [AecLineworkExtend].
Previous post in series [AecLineworkTrim].

I decided not to wait six years between posts on the AEC Modify tools this time. Today's featured command is the AecLineworkDivide command. This command can be accessed on the Home ribbon tab, on the Modify panel flyout or from the right-click context menu (no command active), by choosing AEC Modify Tools > Divide.

The Screencast embedded below shows the AecLineworkDivide command in action. As shown in the Screencast, the command works on linework, Mass Element Extrusions that have an embedded profile, AEC Polygons, Spaces and Block References that contain at least one of the previously mentioned objects. 11/23/2014 Update: "Linework" includes Hatches.

You can specify the dividing line in two ways (just as you could do so for the AecLineworkExtend and AecLineworkTrim commands), either by selecting two points, as was done in the Screencast, or, by pressing the ENTER key when prompted for the first point, and then hovering over an existing line in the file and left clicking when the desired dividing line is highlighted. No matter which method you choose, the dividing line is treated as being infinite in length; the endpoints need not be outside the extents of the selection set.

When a closed item is divided by the AecLineworkDivide command, the resulting objects are also closed, whether the objects are main objects or nested within a Block Reference. A divided circle results in two closed Polylines. A closed Polyline results in (at least) two closed Polylines. An open Polyline results in at least two polylines, and possibly many more, if the dividing line crosses the Polyline multiple times, as it does in the example in the Screencast.

Here are some additional things of which to be aware when using the AecLineworkDivide command:
  • MText, Text, Ellipses and Ellipse Arcs are not dividable and cannot be added to the selection set for the AecLineworkDivide command.
  • Mass Elements with a shape other than "Extrusion" and Mass Element Extrusions that have an external Profile assigned are not dividable. If you include these types of Mass Elements in the selection set of the AecLineworkDivide command, the entire object will be duplicated, even if the dividing line does not intersect the Mass Element.
  • If you divide a Block Reference with dividable nested objects that has just one instance in the file, then the original block definition will be redefined as the objects on one side, and an anonymous block will be created for the objects on the other side. If there are other instances of a Block Reference that are not in the selection set, then the original definition will be left as is, and anonymous block definitions will be created for both sides of the divided Block Reference.
  • When undividable items are present in a block reference that is being divided, the undividable elements will be included in the block definition of both of the newly created blocks.
  • Weird things happen when you divide an attributed block. If there are no dividable objects, the attributed block may be "replaced" with an anonymous block, which may not be annotative even if the original block was. If there are dividable items in the attributed block, then you will likely get two blocks, with the attributes in both, although in my tests the actual instance in the file of one of the blocks did not have the attributes, but inserting another instance of it did result in attributes.
  • Multi-View Blocks are selectable, but will not actually divide, even if the underlying view block contains dividable graphics. The Multi-View Block will duplicate, however (in place), even if it is not cut by the dividing line. This is actually quite handy in the case of a Multi-View Block Space tag, where you are dividing the Space as well. If you include both the Space and the Tag in the same AecLineworkDivide command selection set, then each of the two Spaces created by the divide will be tagged by one of the two Tags generated. You will still have to manually separate the two Tags.
  • In some cases where the object to be divided is irregularly shaped, the divide may create more than two potential objects, for example, a U-shaped closed Polyline or Space divided across the arms of the "U". For the Polyline, you will get three closed Polylines. For the Space, you will only get two Spaces, one of which will have two non-contiguous sub-areas.
  • Walls, Doors, Windows and Door/Window Assemblies do not work well with the AecLineworkDivide command. These items will not be split (not even Walls), but they will duplicate in place, creating, in the case of Walls, cleanup nightmares, and duplicate objects in the other cases. I would not recommend including these items in the selection set of the AecLineworkDivide command.
  • Associative Spaces are also not good candidates for the AecLineworkDivide command. The entire Space will be duplicated, and both will be associative to the same boundaries. I cannot think of a scenario where that would be the desired end result. Non-associative Spaces work just fine, as seen in the Screencast.
  • 11/23/2014 Update: If you select the boundary of an associative Hatch, select the Hatch as well, if you want the Hatch to remain associative and to be associative to the trimmed boundary. Otherwise, the Hatch will become non-associative and retain its extents.

I am sure I have missed some object types or some combination of objects nested inside a Block Reference that have unexpected results when the AecLineworkDivide command is applied. I suggest using the Mark option of the UNDO command to set one or more UNDO Marks prior to using the AecLineworkDivide command in unfamiliar situations, so that you can easily UNDO Back to the Mark if things are not to your liking. That said, there are cases where this command can be handy, when used appropriately.

Next post in the series [AECLineworkSubtract].