@Libbya wrote:
.... some files have the 'Center' linetype loaded and some do not. The above macro works fine if the Center linetype has not been loaded, but gives 'Invalid option keyword.' if Center already exists in the file because if it exists, it asks whether or not you want to reload it. If I add one more enter before celtype then it works if Center is loaded, but fails in a similar manner the first time it is run in a file if the Center linetype does not yet exist in the file.
Is there a way to resolve that discrepancy?
.... after the command has been run and I am finished making the polyline, the cecolor and celtype remain set as they were in the macro. Is there a way to allow an indefinite number of points to the polyline and still reset those variables? Is it possible to also set the layer back to what it was prior to running the macro?
There's an advantage here to using CHPROP after something is drawn -- it doesn't matter whether a linetype is already loaded in the drawing or not; if not, it will find it without the need for loading it previously, unlike the setting of the CELTYPE System Variable. However, to do it that way, you may need an AutoLISP routine rather than a macro [though you can then have a macro that calls for the routine]. Some Lisp functions can be used in macros, but I'm not sure what the limitations are, nor whether the (while) thing looking at CMDACTIVE is one of them -- try it out. If it doesn't allow that, look into setting the EXPERT System Variable -- it may have a setting that will prevent that question from being asked.
There are countless routines on this Forum that save the current values of various System Variables at the beginning, change them for whatever reasons they have, and set them back at the end to what they were before. Search for (getvar 'clayer ... or (getvar "clayer" ... [both (getvar) and (setvar) functions work with either an asterisk-prefixed or a double-quotes-wrapped System Variable name] to find things that include the saving of the current Layer name, which will later use (setvar 'clayer ... or a Layer command's Set option, followed by whatever variable name they used, at the end somewhere, to put it back. In between they will have either a (setvar 'clayer ... function to some other Layer, or a Layer command with the Set or Make option in it. Again, I'm not sure about using those in a macro, but they are standard fare in Lisp routines. The same approach is used for all manner of CE... System Variables in addition to CELTYPE, as well as OSMODE, CMDECHO, BLIPMODE, UCSFOLLOW, EXPERT, QAFLAGS, etc.
Kent Cooper, AIA