Automating “Command line only” operations in AutoCAD – some tips

Over the past 6 months, I have had to resort to command line options for plugins from CadWorx and others. The one was 2DREPH and I wanted to do it on X viewports. I had these viewports in an array, but how can I make a command line string that would consistently work? Well, it came down to making a selection set, then making a group with the same name (prefixed with lets say “GRP”), then using the commandline selection based on group. So, for instance, when prompted for objects here is a selection example:

“SELECT G GRPMYFAVGROUP  ” (note the 2 spaces at the end)

Handy. I then deleted the group to put things back to the way they were.Why? Well…If one uses a click on the object approach (“SELECT M 33,44,55 88,88,99  ” which picks 2 items) if someone places a line or other object at that same location it might not pick the object you intended. Choosing a rectangular select method works, but then you should move the objects to a guaranteed blank-area. Next at those locations (in my case moving a viewports was do-able) THEN do the select by rectangle method, them move the items back. Bottom line – it HAS TO WORK in all situations no matter how or what curve ball the user throws at the tool.