DrollTroll's Toolbox

Started by DrollTroll, June 23, 2011, 02:04:05 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

DrollTroll

This thread (locked for my postings only, sorry) will be a growing collection of macros and other utilities that I hope users may find useful. As I add new entries, I will note them here in the first post, but the actual tool will be in its own reply.

HOW TO USE THESE MACROS:
Click on the macro name below to go directly to the post that contains the attachment. In the post, download the attached macro to your DesignCAD folder. To run the macro, choose Tools/Macro Execute, or press the '%' key, and select the macro from the list.

AVAILABLE MACROS:
FindMicroLines.d3m -- this macro will locate and select line, curve, arrow, and plane entities whose overall length is smaller than some user-specified minimum (default minimum is 0.000001). Added 06/23/2011.

FindTinySegments.d3m -- this macro will locate and select line, curve, arrow, and plane entities which contain one or more segments that is smaller than some user-specified minimum. (How is this different than FindMicroLines? That macro looks at the entire length of the object, this looks at each individual segment within each object.) Added 06/23/2011.

FindSwitchbacks.d3m -- this macro will locate lines, arrows, and planes that double back on themselves (ex. points 1-2 go right, then point 3 is directly to the left of point 2). Usually this is not a desirable thing, so being able to identify these objects can be helpful. Added 06/23/2011.

FindMicroText.d3m -- this macro selects text entities that are suspiciously small (length or height) or are empty strings. Added 06/23/2011.

NoSolids.d3m -- this macro will explode all solids in a drawing by setting everything's solid ID to 0. This is occasionally useful in the 2D version of DesignCAD, which has no command available to explode solids. Added 06/23/2011.

NewMakeXYZ.d3m -- this macro and associated d3i file will create an annotated xyz dump for all selected objects. Added 01/25/2012.

DeleteTinySegments.d3m -- this macro will remove very small segments from multi-segment lines. Added 10/30/2012. Updated 02/14/2013. Updated 03/26/2013. Updated AGAIN 03/29/2013. Thanks samdavo.

FlattenZ.d3m -- this macro will move all points in either the entire drawing or just the selection set to z=0. This can solve many weird problems in what *should* be a 2D drawing but isn't. (I know Lar posted something similar some time back, but I couldn't find it so I rolled my own.) Added 02/14/2013. Updated 04/26/2013 -- fixed problems with Selected Entities Only option. Thanks samdavo.

ApplyLayerStyles.d3m -- updates all entities to use Color By Layer and Linestyle By Layer and re-activates those drawing flags. Added 03/08/2013

Delta.d3m -- this macro measures the delta-x, delta-y, and delta-z offsets between two points that you set. Added 11/12/2014

BalloonsByNumber.d3m -- this macro draws balloons with consecutive numbers. Added 02/06/2015

ChangeCirclesRadius.d3m -- this macro adjusts all selected circles and arcs to a user-specified radius

Two Sample Macros for parsing Solid Surface entity data -- these macros are for illustrative purposes only to demonstrate the BasicCAD mechanisms for retrieving information about Solid Surface entities. Added 06/02/2019

SetViewBySelection -- this macro points the camera to the center of the current selection and lets you rotate the view about that center. Added 06/05/2019

DCParser -- this application can remove entire streams from a drawing file. Mainly useful for fixing drawings with a ridiculous number of unused gradient fills that aren't in use, or that have accumulated a metric ton of hatch patterns or materials that aren't being used. See the linked post for more information. Be warned! This utility can completely destroy a drawing if used improperly. Make a copy of any drawings you will use this tool on. Added 06/08/2019
25 years with DesignCAD

DrollTroll

FindMicroLines.d3m -- this macro will locate and select line, curve, arrow, and plane entities whose overall length is smaller than some user-specified minimum (default minimum is 0.000001). Added 06/23/2011.

25 years with DesignCAD

DrollTroll

#2
FindTinySegments.d3m -- this macro will locate and select line, curve, arrow, and plane entities which contain one or more segments that is smaller than some user-specified minimum. (How is this different from FindMicroLines? That macro looks at the entire length of the object, this looks at each individual segment within each object.) Added 06/23/2011.

25 years with DesignCAD

DrollTroll

#3
FindSwitchbacks.d3m -- this macro will locate lines, arrows, and planes that double back on themselves (ex. points 1-2 go right, then point 3 is directly to the left of point 2). Usually this is not a desirable thing, so being able to identify these objects can be helpful. Added 06/23/2011.
25 years with DesignCAD

DrollTroll

FindMicroText.d3m -- 'Checks for and selects all text with a height or width less than 1e-6 or some user-specified minimum, and all empty text.
This can be especially useful when exporting to DWG or DXF where empy text or text with no length or height can be problematic. Added 06/23/2011.

If any suspicious eintities are selected, the Info Box is opened to allow you to inspect the object(s). Or you can just delete them if you're feeling bold.
25 years with DesignCAD

DrollTroll

NoSolids.d3m -- this macro will explode all solids in a drawing by setting everything's solid ID to 0. This is occasionally useful in the 2D version of DesignCAD, which has no command available to explode solids. Really helpful for those rare occasions where somehow DesignCAD has decided that the entire drawing is a solid, and you can't edit individual entities. Added 06/23/2011.
25 years with DesignCAD

DrollTroll

#6
NewMakeXYZ.d3m and NewMakeXYZ.d3i -- this macro and its associated include file will create an annotated xyz dump of the selected entities. This information can be used in a number of ways -- supplying raw point data to some other application for import or data processing, finding out the exact composition of the selected object(s), verifying that the points of the selected object(s) are in the correct locations, and so forth.

You are required to specify a filename for the xyz file to be created.
*You may supply just a filename (ex. "mydata"), or a full path and filename (ex. C:\Users\Public\mydata").
*The .xyz file extension will be automatically appended.
*If you supply the full path, the specified directory must already exist -- it won't create a new folder for you.
*If you supply the full path, you must have write permissions on the specified folder.
*If you only supply the filename, the data will be saved to one of two places -- either in your My Documents/DesignCAD folder, or in the same folder where DesignCAD was installed.

Be sure to download BOTH attached files to the same folder; the d3m file requires subroutines in the d3i file.

Added 01/25/2012
25 years with DesignCAD

DrollTroll

#7
DeleteTinySegments.d3m -- locates and removes very short segments and duplicate points from lines, arrows, planes, and hatches.
While old versions of DesignCAD were quite tolerant of duplicate points in lines and other entities, newer versions are sometimes less so. Also these can cause problems when trying to export a drawing to dwg or dxf format. Hence this macro. It does NOT remove duplicate points from curves, because in a curve entity two consecutive identical points are used to represent a sharp corner.
Tested on versions 21 and 22, not tested on older versions but should work at least back through version 18.
Todo: Add an option to cancel the operation.
Updated 02/14/2013 -- added a Cancel option (Press Esc) and fixed a potential problem with arrows.
Updated 03/26/2013 -- fixed a problem with locked layers and entities pre-selected.
Updated 03/29/2013 -- sloppy code! Fixed some potential looping errors and other minor issues.
25 years with DesignCAD

DrollTroll

#8
FlattenZ.d3m -- this macro moves all points in either the selection set or the entire drawing (user's choice) to Z = 0. This solves many "weird" problems that may occur when a drawing *should* be 2D but in fact isn't. Should work at least as far back as DesignCAD 3D Max 18, possibly even back to 14.

Note: If your drawing contains 3D solids, or any objects that are not parallel to the XY plane, they can be changed drastically. There is no Undo for this macro, so you may want to save your work before using it. A tilted circle won't be converted to an ellipse, for example -- the center, radius, and orientation points will simply be moved to the Z=0 plane, possibly resulting in a new circle with a different radius.

Updated 04/26/2013 -- fixed some problems with "Flatten Selected Entities Only" option.
25 years with DesignCAD

DrollTroll

#9
ApplyLayerStyles.d3m -- this macro updates all entities in the drawing to use Color By Layer and Linestyle By Layer, and re-activates the Color By Layer and Linestyle By Layer drawing flags. This can be handy if someone has gone and drawn stuff on your preset layers in the wrong color or linestyle.

Added 03/08/2013
25 years with DesignCAD

DrollTroll

#10
Delta.d3m -- this macro asks you to set two points, then displays the distance between them as separate dx, dy, and dz values. Handy if you want more detailed info than just absolute distance.

Note: For version 25, we added this additional information into the Angle and Distance Between Points command (in previous versions it only showed the overall distance).
25 years with DesignCAD

DrollTroll

#11
BalloonsByNumber.d3m --  this macro asks for some starting specifications for balloon text (balloon size, arrow size, and starting number), then continually draws balloons with incrementing numbers until you press the Esc key.
25 years with DesignCAD

DrollTroll

#12
ChangeCirclesRadius.d3m -- this macro asks for a new radius, then updates all selected circles and arcs to use the new radius. All other selected entity types are ignored.
25 years with DesignCAD

DrollTroll

Back in DesignCAD 3D Max 24 we introduced Solid Surface entities, and in DesignCAD 3D Max 25 we added BasicCAD support for them. Though the new BasicCAD features were described in the Release Notes, no working examples were provided. Here are two macros that will hopefully give you a better idea of how to use BasicCAD to parse information about Solid Surface entities.
When I get a spare moment I will also try to update the NewMakeXYZ macro to support Solid Surface entities (and MultiLines for that matter).
25 years with DesignCAD

DrollTroll

#14
Often it's useful to select an object, then center the view on that selection and rotate about the selection's center. That's what this attached macro does. To use it, select one or more objects in 3D Mode, then use Tools/Macro Execute, and run the SetViewBySelection.d3m macro. The view's center will set to the selection center, and you can now drag the mouse to rotate the view centered on that point.
Originally posted 06/05/2019
25 years with DesignCAD