ready2goriding Posted May 3, 2010 Posted May 3, 2010 These commands are not working very well. Is there somewhere I can look for instructions pertaining to their use in lisp routines? None of my currently bookmarked sites seem to go into much detail. Thanks, doug Quote
Lee Mac Posted May 3, 2010 Posted May 3, 2010 What is going wrong? What code is causing the error? There are alternatives - like vla-offset for example, but lets see if we can resolve your issues first Quote
ready2goriding Posted May 3, 2010 Author Posted May 3, 2010 I don't think it is a particular code as much as it is my ignorance. For example, I do not know how to select the line to offset in my routine, can't seem to select the proper trim lines, etc. I haven't tried many commands besides lines & arcs yet with my routines, so I am basically looking to expand- however I cannot make the commands work. Does that make any sense? Thanks, doug Quote
ready2goriding Posted May 3, 2010 Author Posted May 3, 2010 To clarify, I was trying to select points because I'm not sure how to select lines from within my lisp routines. That doesn't seem to work! Quote
alanjt Posted May 3, 2010 Posted May 3, 2010 Very very very simple example of using the Offset command within LISP. (defun c:TEst (/ dist ent pt) (and (setq dist (getdist "\nSpecify offset distance: ")) (setq ent (entsel "\nSelect object to offset: ")) (setq pt (getpoint "\nSpecify point on side to offset: ")) (command "_.offset" dist ent "_non" pt "") ) (princ) ) Quote
ready2goriding Posted May 3, 2010 Author Posted May 3, 2010 I see now. I was trying to get fancy and have the program do all of the work. I didn't want to have the user select anything with the exception of top & bottom center points. I will explore "entities" further and see if that can fix me up! Thank you, alanjt! Quote
alanjt Posted May 3, 2010 Posted May 3, 2010 I see now. I was trying to get fancy and have the program do all of the work. I didn't want to have the user select anything with the exception of top & bottom center points. I will explore "entities" further and see if that can fix me up!Thank you, alanjt! You'll have to post an example. I am completely lost to what you just said. We are more than happy to help. Quote
ready2goriding Posted May 3, 2010 Author Posted May 3, 2010 Good point. I confused myself a little... This box represents a cabinet. My lisp will eventually add or subtract length to the cabinet while keeping the end compartments at a constant dimension. To make it interesting, the center divider at the top is a constant also. I chose to achieve this by: 1- draw a center line from top to bottom. 2- offset 8" to either side in order to clear the top, center compartment. 3- offset each of these new lines 6" to the outside, and trim the top & bottom lines between them. I hope this helps, doug TesT.dwg Quote
ready2goriding Posted May 4, 2010 Author Posted May 4, 2010 I think I am starting to understand. I was attempting to make the offest command automatically enter it's own numbers and points. I guess the user (me!) still has to supply the inputs that the command needs to run. I can work with that! Thanks for the help, all! Back to it... Quote
ready2goriding Posted May 4, 2010 Author Posted May 4, 2010 Very very very simple example of using the Offset command within LISP. (defun c:TEst (/ dist ent pt) (and (setq dist (getdist "\nSpecify offset distance: ")) (setq ent (entsel "\nSelect object to offset: ")) (setq pt (getpoint "\nSpecify point on side to offset: ")) (command "_.offset" dist ent "_non" pt "") ) (princ) ) Can someone please tell me what the "(and)" function is? This may be my whole problem? Thanks, doug Quote
Lee Mac Posted May 4, 2010 Posted May 4, 2010 Its Alan's way of making testing for null user input - it works as the AND statement will stop evaluating expressions as soon as it reaches an expression that returns nil. But I don't like that construct in a whole program IMO. Quote
ready2goriding Posted May 4, 2010 Author Posted May 4, 2010 Its Alan's way of making testing for null user input - it works as the AND statement will stop evaluating expressions as soon as it reaches an expression that returns nil. But I don't like that construct in a whole program IMO. I see, thanks. I guess that wasn't my problem! lol Quote
fixo Posted May 4, 2010 Posted May 4, 2010 I see, thanks. I guess that wasn't my problem! lol I don't understand what you exactly need Just a quick code: (defun c:ofc (/ ang cp1 cp2 en1 en2 ent1 ent2 obj1 obj2 tp1 tp2 up1 up2) (setq ent1 (entsel "\nSelect first line : ") ent2 (entsel "\nSelect second line : ") en1 (car ent1) en2 (car ent2) obj1 (vlax-ename->vla-object en1) obj2 (vlax-ename->vla-object en2) cp1 (vlax-curve-getclosestpointto obj1 (vlax-curve-getpointatparam obj1 (/ (- (vlax-curve-getendparam obj1)(vlax-curve-getstartparam obj1)) 2))) cp2 (vlax-curve-getclosestpointto obj2 cp1) ang (angle cp1 (vlax-curve-getstartpoint obj1)) up1 (polar cp1 ang 2);<-- 2 is offset distance up2 (polar cp1 (+ pi ang) 2) tp1 (polar cp2 ang 2) tp2 (polar cp2 (+ pi ang) 2) ) (command "._line" "_non" up1 "_non" tp1 "" "._line" "_non" up2 "_non" tp2 "" ) (princ) ) (vl-load-com) (princ "\n *** Start command with OFC to excute ***") (prin1) On the picture should be Select first line, Select second line ~'J'~ Quote
ready2goriding Posted May 4, 2010 Author Posted May 4, 2010 Hi, fixo! I am just trying to understand how to make a "trim" command work in lisp. I am a lisping rookie- as you can tell! I will study your code and see if I can understand anything that I am missing. That may take a while... Basically, when I right-click to enter my trimming selections- the function ends. There is much in your code that I do not comprehend yet, so I may have jumped into this project too early... Thank you, doug Quote
alanjt Posted May 4, 2010 Posted May 4, 2010 Its Alan's way of making testing for null user input - it works as the AND statement will stop evaluating expressions as soon as it reaches an expression that returns nil. But I don't like that construct in a whole program IMO. Many people use that method. The only other logical way you could write that would be to use (if (and the 3 prompts) (offset)) but in that situation, you've only added an an additional check. AND would be required either way. Quote
Lee Mac Posted May 4, 2010 Posted May 4, 2010 I'm not sure what you are saying - the princ is not within the AND statement, and, when called without a string or file descriptor, will return a null symbol ( "" ). Quote
ready2goriding Posted May 4, 2010 Author Posted May 4, 2010 I'm sorry. Confused between "exit cleanly" & "nill". Totally silly of me... I've been real silly on this learning curve so far. Quote
ready2goriding Posted May 5, 2010 Author Posted May 5, 2010 Very very very simple example of using the Offset command within LISP. (defun c:TEst (/ dist ent pt) (and (setq dist (getdist "\nSpecify offset distance: ")) (setq ent (entsel "\nSelect object to offset: ")) (setq pt (getpoint "\nSpecify point on side to offset: ")) (command "_.offset" dist ent "_non" pt "") ) (princ) ) Would it be possible to post a similar example of the "move" command, or point me towards a routine that contains it? I am having no luck with this command at all, and can't seem to find any examples... I hate being the rookie- still! Thanks, doug Quote
Lee Mac Posted May 5, 2010 Posted May 5, 2010 A very simple code using Move - obviously this code is redundant, with no advantage over the move command, but it serves as an example. (defun c:test ( / ss p1 p2 ) (if (and (setq ss (ssget "_:L")) (setq p1 (getpoint "\nSpecify Base Point: ")) (setq p2 (getpoint "\nSpecify Next Point: " p1))) (command "_.move" ss "" p1 p2)) (princ)) 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.