RussP Posted February 23, 2015 Share Posted February 23, 2015 I have a brief, simple lisp that I downloaded from AfraLisp and modified for our use. It works well if the drawing already has the attributed block that the routine is looking for, but there are more blocks with attributes in the drawings we have and if the one the routine is looking for is not there it deletes the other block, or blocks, such as the title block. The code doesn't allow for a check of the inserted blocks and then insert it if it isn't there. I have attached the code for someone, anyone, to look at. It is a simple fix I'm sure but the syntax escapes me. Thanks for any help, Russ App - Test.lsp Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted February 23, 2015 Share Posted February 23, 2015 After a cursory glance, change: (if (= "DwgDate") ;if the block name is "DwgDate" to: (if (= "DwgDate" blkn) ;if the block name is "DwgDate" Though, several other improvements could also be made. Quote Link to comment Share on other sites More sharing options...
RussP Posted February 23, 2015 Author Share Posted February 23, 2015 Yes, I do think it could be more efficient and even accommodate some other user conditions. If you would like to make some suggestions I would be very grateful for the help. Quote Link to comment Share on other sites More sharing options...
BIGAL Posted February 24, 2015 Share Posted February 24, 2015 Could you explain a bit more exactly what it is that your trying to achieve. Quote Link to comment Share on other sites More sharing options...
RussP Posted February 24, 2015 Author Share Posted February 24, 2015 We produce shop drawings for structural steel and during the approval process the stamp on the drawings changes based on whether the drawings are for approval or fabrication. The text of the stamp is already in the drawing and it is a simple matter of changing which layer is on and then manually changing the date. Easy, but time consuming if you have hundreds of drawings to do in a day. So I wrote a simple layer change. Then I thought it would be nice if the date changed with the layer since we have to change the date on each drawing when it is issued. So I found a date change routine on the AfraLisp site that looked like it would work for what I was trying to do. And it did work, except when the attributed block had not been inserted into the drawing yet. Which is the case in all of the old drawings and in the drawings of the other detailer here who hasn't yet incorporated the attributed block into his prototype drawings. So when I would use the application in his drawings, or any drawing that did not have the attributed block for the date in it, the routine would erase the title block, because it has attributes. So I thought that it would be better if the routine looked for an instance of the block in the drawing first, if it wasn't there then insert it, and then finish with the rest of the task without erasing the the title block. The suggestion from Lee Mac seems to work. I only had a chance to test it a few times. Although I have been working with Autolisp since the early nineties I don't consider myself a programmer, as evidenced by my missing the simple fix that Lee Mac provided. But I am always interested in learning, especially those nifty little tips that work wonders in making the code more efficient and, of course, more bulletproof. I need to add an error routine to the mix since it turns on and off different settings. And when the user exits prematurely now those setting are left hanging. I would like to have everything back to where it was should there be a sudden need to hit the escape key. The routine is not too complicated, but it is very productive in our workday. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.