Tips & Bits...‎ > ‎

Entmaking XLINEs

posted Feb 24, 2013, 12:12 PM by Reinaldo Togores Fernández
Some days ago Hutter7405 posted this question in the forum:
I created an XLine function that when I type XV or XH puts a vertical or horizontal XLine on the Defpoints layer and automatically switches back to the previous layer. How do I make it so the function stays on Defpoints until you hit ESC then it returns to the original layer?
The function he created depended on calling the AutoCAD commands "_-LAYER" and "_XLINE" using the AutoLISP command function. Su he had to create or set the "Defpoints" layer as current, draw the XLINEs and when finished, return to the previous layer. This can be done, but it is unnecessarily complicated.
A simpler way would be to use the AutoLISP entmake function that can create an entity on any layer even if it not the current one. So no need to change the current layer. But, in addition, when entmake creates an entity on a non-existent layer, the layer will be automatically created.