harrison-matt Posted October 19, 2010 Posted October 19, 2010 All, I am having a hard time getting the Getstring function to disallow a blank "" return. I have tried (initget 1) but that does not work for the getstring function. This is my getstring: (setq strg (getstring T "\nBox Content")) I tried looping with while and since the command would not return nil when pressing enter it entered a loop forcing me to end task. then i attempted Cond, same thing.. any suggestions? Thanks, Matt Quote
harrison-matt Posted October 19, 2010 Author Posted October 19, 2010 (setq pt1 (getpoint "\nFirst corner of box:")) (initget 32) (setq pt2 (getcorner pt1 "\nFinal corner of box: ")) (setq inside (getstring T "\nContents within box: ")) (setq ang (angtos (angle pt1 pt2) 0 ) And why is this looping? I am soo confused Quote
BlackBox Posted October 19, 2010 Posted October 19, 2010 Perhaps this will help: (defun c:FOO (/ pt1 pt2 inside ang) (if (setq pt1 (getpoint "\nFirst corner of box:")) (progn (initget 32) (setq pt2 (getcorner pt1 "\nFinal corner of box: ")) (if (setq inside (getstring T "\nContents within box: ")) (while (= "" inside) (setq inside (getstring T "\nInvalid Input, Enter Contents within box: ")))) (setq ang (angtos (angle pt1 pt2) 0 ) ;; ...Code )) (princ)) Quote
Lt Dan's legs Posted October 19, 2010 Posted October 19, 2010 (edited) (setq ang (angtos (angle (setq pt1 (getpoint "\nFirst corner of box:")) (setq pt2 (getcorner pt1 "\nFinal corner of box: ")) ) 0 8 ) ) (initget 32) (while (eq (setq inside (getstring T "\nContents within box: ")) "") (prompt "\nPlease type in something!!!!!") ) Edited October 19, 2010 by Lt Dan's legs because I'm bored Quote
alanjt Posted October 19, 2010 Posted October 19, 2010 (and (setq pt1 (getpoint "\nFirst corner of box:")) (setq pt2 (getcorner pt1 "\nFinal corner of box: ")) (/= "" (setq inside (getstring T "\nContents within box: "))) (setq ang (angtos (angle pt1 pt2) 0 ) ) Quote
harrison-matt Posted October 19, 2010 Author Posted October 19, 2010 Thanks for the help!, i have another question and i figure i'll just post it here instead of creating a new thead. Visual lisp question: I am trying to place text using VLA-ADDTEXT and i am getting this error: "lisp value has no coercion to VARIANT with this type: (5.59997 12.8634 0.0)" (vl-load-com) (setq doc (vla-get-ActiveDocument (vlax-get-Acad-Object)) spc (if (zerop (vla-get-activespace doc)) (if (= (vla-get-mspace doc) :vlax-true) (vla-get-modelspace doc) (vla-get-paperspace doc)) (vla-get-modelspace doc))) (if (setq inside (getstring T "\nContents within box: ")) (while (= "" inside) (setq inside (getstring T "\nInvalid Input, Enter Contents within box: ")))) (setq begin (getpoint "\nCenter of Cell: ")) (VLA-ADDTEXT spc INSIDE BEGIN 0.09375) Any ideas? matt Quote
BlackBox Posted October 19, 2010 Posted October 19, 2010 Try (rtos begin 2 5) Why??? Command: (setq begin (list 5.59997 12.8634 0.0)) (5.59997 12.8634 0.0) Command: (rtos begin 2 5) ; error: bad argument type: numberp: (5.59997 12.8634 0.0) Quote
Lee Mac Posted October 19, 2010 Posted October 19, 2010 Another possible angle to approach it... (defun c:test ( / inside begin ) (vl-load-com) (while (= "" (setq inside (getstring t "\nContents Within Box: "))) (princ "\n** You're doing it wrong **") ) (if (setq begin (getpoint "\nPick that Center: ")) (vla-AddText (vlax-get-property (vla-get-ActiveDocument (vlax-get-acad-object)) (if (= 1 (getvar 'CVPORT)) 'PaperSpace 'ModelSpace) ) inside (vlax-3D-point begin) 0.09375 ) ) (princ) ) Quote
Lt Dan's legs Posted October 19, 2010 Posted October 19, 2010 ...because i'm an idiot! please ignore _______ I don't know why I was thinking of angle Quote
Sweety Posted October 19, 2010 Posted October 19, 2010 ...because i'm an idiot! please ignore I don't know why I was thinking of angle No you're not. Anyone gonna make mistakes, but the smart one who do not repeat it again. Best regards DAN. _______ Quote
harrison-matt Posted October 19, 2010 Author Posted October 19, 2010 OK GREAT! So i have created the text, I trying though to put the text in as middle center alignment. I did this: (vl-load-com) (setq doc (vla-get-ActiveDocument (vlax-get-Acad-Object)) spc (if (zerop (vla-get-activespace doc)) (if (= (vla-get-mspace doc) :vlax-true) (vla-get-modelspace doc) (vla-get-paperspace doc)) (vla-get-modelspace doc))) (setq begin (getpoint "\nCenter of Cell: ")) (setq 3dpt (vlax-3d-POINT begin)) (if (setq inside (getstring T "\nContents within box: ")) (while (= "" inside) (setq inside (getstring T "\nInvalid Input, Enter Contents within box: ")))) (setq slen (strlen inside)) (SETQ TEXT (VLA-ADDTEXT spc INSIDE 3dpt 0.09375)) (vla-put-alignment text 10) I know the property that needs to change and to what value but how do I execute the command with the text comming in at the point specified with alignment of 10 (middle center)? Any thoughts? Matt Quote
Lee Mac Posted October 19, 2010 Posted October 19, 2010 As a modification of my previous post: (defun c:test ( / inside begin tobj ) (vl-load-com) (while (= "" (setq inside (getstring t "\nContents Within Box: "))) (princ "\n** You're doing it wrong **") ) (if (setq begin (getpoint "\nPick that Center: ")) (progn (setq tObj (vla-AddText (vlax-get-property (vla-get-ActiveDocument (vlax-get-acad-object)) (if (= 1 (getvar 'CVPORT)) 'PaperSpace 'ModelSpace) ) inside (vlax-3D-point begin) 0.09375 ) ) (vla-put-Alignment tObj acAlignmentMiddleCenter) (vla-put-TextAlignmentPoint tObj (vlax-3D-point begin)) ) ) (princ) ) Quote
Lee Mac Posted October 19, 2010 Posted October 19, 2010 (vla-put-attachmentpoint text acattachmentpointmiddlecenter) He's dealing with Text matey Quote
BlackBox Posted October 19, 2010 Posted October 19, 2010 He's dealing with Text matey Yeah, I noticed that afterword... post deleted. Quote
harrison-matt Posted October 19, 2010 Author Posted October 19, 2010 Alright now to sum up my lesson how would you do the same thing using entmake or entmakex? Quote
Lee Mac Posted October 19, 2010 Posted October 19, 2010 (defun c:test ( / inside begin ) (while (= "" (setq inside (getstring t "\nContents Within Box: "))) (princ "\n** You're doing it wrong **") ) (if (setq begin (getpoint "\nPick that Center: ")) (entmakex (list (cons 0 "TEXT") (cons 10 begin) (cons 1 inside) (cons 40 0.09375) (cons 72 1) (cons 73 2) (cons 11 begin) ) ) ) (princ) ) Quote
Lee Mac Posted October 19, 2010 Posted October 19, 2010 Needs an updated, but see here: http://www.cadtutor.net/forum/showthread.php?44768-Entmake-Functions Quote
BlackBox Posted October 19, 2010 Posted October 19, 2010 Alright now to sum up my lesson how would you do the same thing using entmake or entmakex? ... Provide the needed eList data to entmake and entmakex accordingly? lol 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.