Jump to content

Recommended Posts

Posted

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

  • Replies 31
  • Created
  • Last Reply

Top Posters In This Topic

  • harrison-matt

    12

  • BlackBox

    7

  • Lee Mac

    6

  • Lt Dan's legs

    3

Popular Days

Top Posters In This Topic

Posted Images

Posted

 
(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

Posted

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))

Posted (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 by Lt Dan's legs
because I'm bored
Posted
(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 )
)

Posted

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

Posted
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)

Posted

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)
)

Posted

...because i'm an idiot! :oops:

 

please ignore

 

 

_______

 

I don't know why I was thinking of angle

Posted
...because i'm an idiot! :oops:

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.

_______

Posted

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

Posted

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)
)

Posted
(vla-put-attachmentpoint text acattachmentpointmiddlecenter)

 

He's dealing with Text matey :)

Posted
He's dealing with Text matey :)

 

Yeah, I noticed that afterword... post deleted.

Posted

Alright now to sum up my lesson how would you do the same thing using entmake or entmakex?

 

:)

Posted
(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)
)

Posted
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

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...