BlackBox Posted August 26, 2011 Posted August 26, 2011 Based on a previous post, I just removed a pair of parentheses from the T condition and now everything works fine. Grrrrrr. Maybe I just can't count, but I imagined the structure of the T case to be the same as the others. (cond ( (if case 1) (do stuff)) ( (if case 2) (do stuff)) ( T (do stuff)) ) But apparently it's (cond ( (if case 1) (do stuff)) ( (if case 2) (do stuff)) ( T do stuff) ) I've spent several hours the last few days sweating over this one part, and all it was was a couple of extra parentheses. I'll be facepalming myself for a while now. No worries; we all start somewhere. Syntax is important, if you're not already doing so, use the Visual LISP Integrated Development Environment (IDE) for writing, & debugging your code. Simply use the VLIDE command to access. Really it depends on the 'result' expressions that follow the 'test' expression. If you have an actual routine in mind, perhaps we can help? [edit] For example, in the case where: (defun DO_STUFF () "DO STUFF") ... then the first syntax IS correct. However, if "Do Stuff" represents several expressions, then the latter syntax *may* be appropriate. [/edit] Side note - SLW get's angry when you don't use , and you wouldn't like him when he's angry. Quote
Comatosis Posted August 26, 2011 Author Posted August 26, 2011 The routine I'm working on was the one that prompted me to make this thread (and sign up to cadtutor, as a matter of fact ). It's nothing else than a routine to spit out an alert if I'm missing any keyed notes on my sheets or their definitions/descriptions (the alert tells me which specifically I'm missing). Happily I can say that it's fully functional as of 5 minutes ago, however, so this is a big "BOOYA!!" moment for me. Appreciate all the help from everyone. I shall be visiting this website regularly for all my autocad needs, heh. p.s. I already write all my code on VLIDE, as opposed to using notepad and importing it in. I need to get better acquainted with the debug features, though. p.p.s. Sorry for the missing CODE tags. Quote
BlackBox Posted August 27, 2011 Posted August 27, 2011 Congrats; See you around the forums. :wink: PS - Check out Lee Mac's website, he's written excellent tutorials on VLIDE. Quote
Lee Mac Posted August 27, 2011 Posted August 27, 2011 ...and I have no idea where it occurs because stepping through each line on debug mode for some reason is not highlighting the lines as I go through them More useful I find is the [ 'Break on Error' / 'Last Break Source' ] method of detecting where code fails. I describe this method in my tutorial here, under the heading 'Where did the Code Fail?' PS - Check out Lee Mac's website, he's written excellent tutorials on VLIDE. Thanks for the nod mate Quote
Comatosis Posted August 29, 2011 Author Posted August 29, 2011 Alright, so I thought my code was fully functional last week until I encountered yet another minor bug. How would I go about removing tab indicators from text or mtext? What I had was this: (repeat (strlen str) (setq str (vl-string-subst "" "\\\t" str))) I removed paragraph indicators this way, but the couple of tabs I tried out just wouldn't go away. Quote
Lee Mac Posted August 29, 2011 Posted August 29, 2011 How would I go about removing tab indicators from text or mtext?I removed paragraph indicators this way, but the couple of tabs I tried out just wouldn't go away. Use this, Joe has put a lot of work into it's development. Quote
Comatosis Posted August 29, 2011 Author Posted August 29, 2011 Actually, I want this done within the code, without editing the text on my sheets; sorry for not making this clear. I think Renderman's link would do the trick, in particular this part: (while (vl-string-search "\t" s) (setq s (vl-string-subst "" "\t" s))) I'll get to work and see if I can some form of the above to work. Thanks. EDIT: The code I had actually worked after I changed the search pattern to "\t", which is weird because this wouldn't work when I was trying it out for paragraphs and I ended up getting it to work with "\\\P". Quote
BlackBox Posted August 29, 2011 Posted August 29, 2011 While I appreciate the nod, Comatosis; just be warned MText formatting can be quite complex and the linked code is as stated... only an 'example'. Quote
Lee Mac Posted August 29, 2011 Posted August 29, 2011 Actually, I want this done within the code You should be able to call the subfunctions from StripMText with the necessary arguments. Quote
Comatosis Posted August 29, 2011 Author Posted August 29, 2011 Thinking ahead, would it be relatively feasible to run my routine on multiple drawings at once and provide some form of report for all of them? My loose research on accessing other dwg files makes it sound as if it's tougher than it would seem. Quote
irneb Posted August 30, 2011 Posted August 30, 2011 At a guess, you should be able to run your code through some form of scripting. There are several ways you could try to do this, I just prefer using AutoScript since it works inside of ACad (unlike ScriptPro does) and it has a lot more error-trapping than trying to just use a script-generator. But it's up to you which you prefer, the generator usually gives a bit more speed though. Or you could create your own "script" to load multiple DWGs and run your code - manually, but that's a lot of work that's not necessary. As for having a report at the end, you could always open a text file in append mode and write the changes / checks made of each DWG to its end. Just remember to close it in each case, otherwise you might have some error happening. Quote
BlackBox Posted August 30, 2011 Posted August 30, 2011 Thinking ahead, would it be relatively feasible to run my routine on multiple drawings at once and provide some form of report for all of them? My loose research on accessing other dwg files makes it sound as if it's tougher than it would seem. ... Forgive my laziness, I've not gone back and re-read the entire six pages of this thread; given your explicit comment(s) here, why is it that this wouldn't work again? Quote
Comatosis Posted August 30, 2011 Author Posted August 30, 2011 It's not that it wouldn't work, it's that I want to write the routines myself so that I can learn how to do this stuff. I learn more by doing rather than just reading. I'm sure I could also download/purchase all kinds of programs to do everything I could conceivably want, but where's the fun in that? Yeah, I may as well be reinventing the wheel with what I'm doing, but all the same, it's a good learning opportunity. Quote
BlackBox Posted August 30, 2011 Posted August 30, 2011 It's not that it wouldn't work, it's that I want to write the routines myself so that I can learn how to do this stuff. I learn more by doing rather than just reading. I'm sure I could also download/purchase all kinds of programs to do everything I could conceivably want, but where's the fun in that? Yeah, I may as well be reinventing the wheel with what I'm doing, but all the same, it's a good learning opportunity. ... And that is perfectly fine; I too find it better to learn by writing the code myself, and debugging, etc.. Again, by not re-reading the entire thread, perhaps I missed where that was the stated intent. I only thought to reiterate, (incorrectly-)thinking that this was more about *getting the job done now* and not an educational exercise. Cheers! Quote
Comatosis Posted August 30, 2011 Author Posted August 30, 2011 ... And that is perfectly fine; I too find it better to learn by writing the code myself, and debugging, etc.. Again, by not re-reading the entire thread, perhaps I missed where that was the stated intent. I only thought to reiterate, (incorrectly-)thinking that this was more about *getting the job done now* and not an educational exercise. Cheers! I might have misspoken in that sense, but this wasn't an urgent thing where the future of the company rides on this one routine or anything. Otherwise, we would've hired an IT team for it, heh. I figured this particular function was good for both speeding up our design process as well as getting some programming experience. Now I'm going, "ok, now that I've done this, how can I make it better?" Quote
Comatosis Posted August 30, 2011 Author Posted August 30, 2011 I think I'm surprisingly close to what I wanted, but I might have to re-think the way I'm doing this. I have a drawing open, and from that drawing I get the path, drawing names in the directory, etc. to build my script (which is to run the function I've been bugging you guys about this whole time ). Now, because I have a drawing open, when I run my script AutoCAD is asking me if I want to open my already-open sheet read-only. Regardless of my answer, the script stops executing. Is there a way around this? Ideally I'd like to be able to run my script this in this fashion--limited to the folder I'm already in--as opposed to having the user specify the folder and possibly choosing the wrong one. Thanks. (p.s. Sorry if I'm in the wrong forum for this. I can take my question to the scripting section if needed, though I figured I may as well stick to one topic as much as possible) Quote
BlackBox Posted August 30, 2011 Posted August 30, 2011 (vl-remove-if '(lambda (x / n) (= (cond (n) ((setq n (strcase (getvar 'dwgname))))) (strcase x))) (vl-directory-files (getvar 'dwgprefix) "*.dwg" 1)) Quote
Comatosis Posted August 30, 2011 Author Posted August 30, 2011 Woah, that's awesome. Although, I must say I still don't understand how lambda works just yet. I guess it's somewhat of a function without having to write a function? I shall do my research and figure it out. Thanks for the help. Quote
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.