Lt Dan's legs Posted May 10, 2010 Posted May 10, 2010 Okay new problem but for a similar lisp. I'm trying to get this box to stretch. I'm trying to modify the lisp you provided (alan) to stretch the box to width and length (defun c:[b]Single[/b] (/ blockname p1 p2) ;; Insert and stretch "[color=black][b]singlebox[/b][/color]" block (required) ;; Alan J. Thompson, 05.05.10 (vl-load-com) (setq blockname "[b]singlebox[/b]") (if (and (or (tblsearch "block" blockname) (findfile (strcat blockname ".dwg")) (alert (strcat blockname " cannot be found!")) ) (setq p1 (getpoint "\nSpecify block insertion point: ")) (setq p2 (getpoint p1 "\[b]nSpecify Box width:[/b] ")) ) ((lambda (block) (foreach x (vlax-invoke block 'GetDynamicBlockProperties) (and (eq (vla-get-propertyname x) "[b]width[/b]") (vla-put-value x ((lambda (dist / num) (cond ((>= 1. (/ dist 46.)) (setq num 46.)) ((< 1. (setq num (/ dist 46.))) (setq num (* 46. (1+ (fix num))))) ) num ) (distance p1 p2) ) ) ) ) (vl-catch-all-apply (function (lambda () (vla-explode block) (vla-delete block)))) ) (vla-insertblock (if (or (eq acmodelspace (vla-get-activespace (cond (*AcadDoc*) ((setq *AcadDoc* (vla-get-activedocument (vlax-get-acad-object)))) ) ) ) (eq :vlax-true (vla-get-mspace *AcadDoc*)) ) (vla-get-modelspace *AcadDoc*) (vla-get-paperspace *AcadDoc*) ) (vlax-3d-point (trans p1 1 0)) blockname 1. 1. 1. (angle (trans p1 1 0) (trans p2 1 0)) ) ) ) (princ) ) I've made my changes bold. I want the second prompt to be "\nSpecify Box length: ")). I just don't know how to make it function. Also, how do I remove the 46" increments? Is it as simple as removing ((lambda (dist / num) (cond ((>= 1. (/ dist 46.)) (setq num 46.)) ((< 1. (setq num (/ dist 46.))) (setq num (* 46. (1+ (fix num))))) ) num ) ? I'm really trying to get a grasp on this and I appreciate all the help Quote
alanjt Posted May 10, 2010 Posted May 10, 2010 I'll look at it in a few. However, in the mean time, if you are going to edit code I've posted, please denote your edits (as they are not mine). Quote
Lt Dan's legs Posted May 10, 2010 Posted May 10, 2010 I'll look at it in a few. However, in the mean time, if you are going to edit code I've posted, please denote your edits (as they are not mine). Sorry, I'm still new to all of this. I made my changes bold but I guess its hardly noticeable Quote
alanjt Posted May 10, 2010 Posted May 10, 2010 Sorry' date=' I'm still new to all of this. I made my changes bold but I guess its hardly noticeable[/quote'] Don't sweat it. It just that you've made changes on something I submitted with my name on it, but what you've submitted is partially your work. When editing another person's work, always state where you made edits. Take credit for your work and be proud. Quote
Lt Dan's legs Posted May 11, 2010 Posted May 11, 2010 Hey alan.. I've kind of figured out my problem. this is what I want my box to do but I don't know how to fix the increments (defun c:test (/ blockname p1 p2 P3) (vl-load-com) (setq blockname "1compartment") (if (and (or (tblsearch "block" blockname) (findfile (strcat blockname ".dwg")) (alert (strcat blockname " cannot be found!")) ) (setq p1 (getpoint "\nSpecify block insertion point: ")) (setq p2 (getpoint p1 "\nSpecify box width: ")) (setq p3 (getpoint p2 "\nSpecify box length: ")) ) ((lambda (block) (foreach x (vlax-invoke block 'GetDynamicBlockProperties) (and (eq (vla-get-propertyname x) "DISTANCE") (vla-put-value x ((lambda (dist / num) (cond ((>= 1. (/ dist 1.)) (setq num 1.)) ((< 1. (setq num (/ dist 1.))) (setq num (* 1. (fix num)))) ) num ) (distance p1 p2) ) )) (and(eq (vla-get-propertyname x) "DISTANCE1") (vla-put-value x ((lambda (dist / num) (cond ((>= 1. (/ dist 1.)) (setq num 1.)) ((< 1. (setq num (/ dist 1.))) (setq num (* 1. (fix num)))) ) num ) (distance p2 p3) ) ) ) ) (vl-catch-all-apply (function (lambda () (vla-explode block) (vla-delete block)))) ) (vla-insertblock (if (or (eq acmodelspace (vla-get-activespace (cond (*AcadDoc*) ((setq *AcadDoc* (vla-get-activedocument (vlax-get-acad-object)))) ) ) ) (eq :vlax-true (vla-get-mspace *AcadDoc*)) ) (vla-get-modelspace *AcadDoc*) (vla-get-paperspace *AcadDoc*) ) (vlax-3d-point (trans p1 1 0)) blockname 1. 1. 1. (angle (trans p1 1 0) (trans p2 1 0)) ) ) ) (princ) ) I'm trying to get it to go by the prompt and not by clicking on the screen. distance would go 0º and distance1 would go 90º Quote
alanjt Posted May 11, 2010 Posted May 11, 2010 Don't sweat it. It just that you've made changes on something I submitted with my name on it, but what you've submitted is partially your work. When editing another person's work, always state where you made edits. Take credit for your work and be proud. The increments will be based on whatever you have set in the block. That's where I originally got the 46. from. Quote
Lt Dan's legs Posted May 11, 2010 Posted May 11, 2010 The increments will be based on whatever you have set in the block. That's where I originally got the 46. from. This is a different block. I'm just changing the code to make it work for this Dyn blk. This block is a box with dimensions. I want it to be able to stretch in increments of 1/8" Quote
alanjt Posted May 11, 2010 Posted May 11, 2010 This is a different block. I'm just changing the code to make it work for this Dyn blk. This block is a box with dimensions. I want it to be able to stretch in increments of 1/8" I know, but the Long Wall block's increments were based on 46. You just have to base it on whatever number you used when creating the block (1/8" in this case). Quote
Lt Dan's legs Posted May 11, 2010 Posted May 11, 2010 okay so how do I put that in the code? Everytime I try to change this to a smaller number than one it gives me an input error ((lambda (dist / num) (cond ((>= 1. (/ dist 1.)) (setq num 1.)) ((< 1. (setq num (/ dist 1.))) (setq num (* 1. (fix num)))) ) num ) (distance p2 p3) ) Quote
alanjt Posted May 11, 2010 Posted May 11, 2010 (/ dist 1.) The 1. should be your increment (as I had 46. there). Quote
Lt Dan's legs Posted May 11, 2010 Posted May 11, 2010 (/ dist 1.) The 1. should be your increment (as I had 46. there). When I change it to (/ dist .125) it comes up with "; error: misplaced dot on input" Quote
alanjt Posted May 11, 2010 Posted May 11, 2010 When I change it to (/ dist .125) it comes up with "; error: misplaced dot on input" .125 is not a valid number. Try 0.125 Quote
alanjt Posted May 11, 2010 Posted May 11, 2010 Nice! thanks Did you get it to work? BTW' date=' please heed the following... I'll look at it in a few. However, in the mean time, if you are going to edit code I've posted, please denote your edits (as they are not mine). Don't sweat it. It just that you've made changes on something I submitted with my name on it, but what you've submitted is partially your work. When editing another person's work, always state where you made edits. Take credit for your work and be proud. Quote
Lt Dan's legs Posted May 11, 2010 Posted May 11, 2010 Yes it did. Sorry, I need to practice this. Quote
alanjt Posted May 11, 2010 Posted May 11, 2010 Yes it did. Sorry' date=' I need to practice this.[/quote']Good deal. Sorry I haven't had a chance to open the file and give it a look. No sweat, that's why I reminded you. Quote
Lt Dan's legs Posted May 12, 2010 Posted May 12, 2010 Okay one last question and I swear I'm done with this thread! How do I take the mouse out of the equation? I know by taking the p1 out of the setq p2 & p3 it does the job but the outcome of the box size isn't the numbers I typed in on the line. ;; Alan J. Thompson, 05.05.10 ;; parts modified by Reid B. 05.12.10 (defun c:COMP1 (/ blockname p1 p2 P3);; modified by Reid b. (vl-load-com) (setq blockname "1compartment") (if (and (or (tblsearch "block" blockname) (findfile (strcat blockname ".dwg")) (alert (strcat blockname " cannot be found!")) ) (setq p1 (getpoint "\nSpecify block insertion point: ")) (setq p2 (getpoint p1 "\nSpecify box width: ")) ;; modified by Reid b. (setq p3 (getpoint p1 "\nSpecify box length: ")) ;;by Reid b. ) ((lambda (block) (foreach x (vlax-invoke block 'GetDynamicBlockProperties) (and (eq (vla-get-propertyname x) "DISTANCE") (vla-put-value x ((lambda (dist / num) (cond ((>= 0.125 (/ dist 0.125)) (setq num 0.125)) ((< 0.125 (setq num (/ dist 0.125))) (setq num (* 0.125 (fix num)))) ) num ) (distance p1 p2) ) )) ;; modified by Reid b. (and(eq (vla-get-propertyname x) "DISTANCE1") (vla-put-value x ((lambda (dist / num) (cond ((>= 0.125 (/ dist 0.125)) (setq num 0.125)) ((< 0.125 (setq num (/ dist 0.125))) (setq num (* 0.125 (fix num)))) ) num ) (distance p1 p3) ) ;;by Reid b. ) ) ) (vl-catch-all-apply (function (lambda () (vla-explode block) (vla-delete block)))) ) (vla-insertblock (if (or (eq acmodelspace (vla-get-activespace (cond (*AcadDoc*) ((setq *AcadDoc* (vla-get-activedocument (vlax-get-acad-object)))) ) ) ) (eq :vlax-true (vla-get-mspace *AcadDoc*)) ) (vla-get-modelspace *AcadDoc*) (vla-get-paperspace *AcadDoc*) ) (vlax-3d-point (trans p1 1 0)) blockname 1. 1. 1. 0. (angle (trans p1 1 0) (trans p2 1 0)) ;; modified by Reid b. ) ) ) (princ) ) Quote
Lee Mac Posted May 12, 2010 Posted May 12, 2010 Use GetDist in place of GetPoint for p2, p3 (some other parts of the code will need to be modified also. Quote
alanjt Posted May 12, 2010 Posted May 12, 2010 Use GetDist in place of GetPoint for p2, p3 (some other parts of the code will need to be modified also. There you go. Thanks Lee. 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.