Jump to content

Getstring Question


harrison-matt

Recommended Posts

Oh and man i was close, before i checked back here i was hot on the tail of

(vla-put-textalignmentpoint TEXT (vlax-3d-point begin))

.

 

Thanks,

 

matt

Link to comment
Share on other sites

  • 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

All,

 

If we can revisit this, i am having some trouble with creating a polyline:

  (while (= "" (setq content (getstring t "\nContents Within Box: ")))
   (princ "\nInvalid key: Enter the contents: "))
 (if (setq point (getpoint "\nCenter of cell: "))
   (progn (setq tObj (vla-AddText
  (vlax-get-property (vla-get-ActiveDocument (vlax-get-acad-object))
    (if (= 1 (getvar 'CVPORT)) 'PaperSpace 'ModelSpace))
  content
  (vlax-3D-point point)
  0.09375))
     (vla-put-Alignment tObj acAlignmentMiddleCenter)
     (vla-put-TextAlignmentPoint tObj (vlax-3D-point point))
     (setq BL (+ (* (strlen content) 0.1) 0.2))
     (setq P1 (polar (polar point pi (/ bl 2)) (/ pi 2) 0.125)
    p2 (polar p1 (/ (* 3 pi) 2) 0.25)
    p3 (polar (polar point 0 (/ bl 2)) (/ (* 3 pi) 2) 0.125)
    p4 (polar p3 (/ pi 2) 0.25))        
     (entmakeX (list (cons 0 "LWPOLYLINE")
       (cons 100 "AcDbEntity")
       (cons 100 "AcDbPolyline")
       (cons 70 1)
       (cons 90 4)
       (cons 10 p1)
       (cons 11 p2)
       (cons 12 p3)
       (cons 13 p4)
       (cons 39 0.01)))))

Link to comment
Share on other sites

All,

 

If we can revisit this, i am having some trouble with creating a polyline:

 
(while (= "" (setq content (getstring t "\nContents Within Box: ")))
   (princ "\nInvalid key: Enter the contents: "))
 (if (setq point (getpoint "\nCenter of cell: "))
   (progn (setq tObj (vla-AddText
  (vlax-get-property (vla-get-ActiveDocument (vlax-get-acad-object))
    (if (= 1 (getvar 'CVPORT)) 'PaperSpace 'ModelSpace))
  content
  (vlax-3D-point point)
  0.09375))
     (vla-put-Alignment tObj acAlignmentMiddleCenter)
     (vla-put-TextAlignmentPoint tObj (vlax-3D-point point))
     (setq BL (+ (* (strlen content) 0.1) 0.2))
     (setq P1 (polar (polar point pi (/ bl 2)) (/ pi 2) 0.125)
    p2 (polar p1 (/ (* 3 pi) 2) 0.25)
    p3 (polar (polar point 0 (/ bl 2)) (/ (* 3 pi) 2) 0.125)
    p4 (polar p3 (/ pi 2) 0.25))        
     (entmakeX (list (cons 0 "LWPOLYLINE")
       (cons 100 "AcDbEntity")
       (cons 100 "AcDbPolyline")
       (cons 70 1)
       (cons 90 4)
       (cons 10 p1)
       (cons 1[color=red]1[/color] p2)
       (cons 1[color=red]2[/color] p3)
       (cons 1[color=red]3[/color] p4)
       (cons 39 0.01)))))

 

 

Okay... I wonder what kind of trouble? :twisted:

 

Perhaps a closer analysis of your code shall *reveal* something worthy of note? :geek:

 

... But then again, the polyline would still not yet be closed. :twisted:

Link to comment
Share on other sites

I did briefly, I am confused on the lambda, function, append bit and willl revisit that later.

 

Perhaps a closer analysis of your code shall *reveal* something worthy of note?

 

... But then again, the polyline would still not yet be closed.

 

... If only you were able to look at your code through my eyes (or my post?), as if I'd left you hint of where to look. :wink:

Link to comment
Share on other sites

I actually have picked up on your hint and moved on, ps i the polyline closes now as well, just alittle re-arranging etc. Here it is:

(defun c:test ( / content point tobj BL p1 p2 p3 p4)
 (vl-load-com)
 
 (while (= "" (setq content (strcase (getstring t "\nContents Within Box: "))))
   (princ "\nInvalid key: Enter the contents: "))
 (if (setq point (getpoint "\nCenter of cell: "))
   (progn (setq tObj (vla-AddText
  (vlax-get-property (vla-get-ActiveDocument (vlax-get-acad-object))
    (if (= 1 (getvar 'CVPORT)) 'PaperSpace 'ModelSpace))
  content
  (vlax-3D-point point)
  0.09375))
     (vla-put-Alignment tObj acAlignmentMiddleCenter)
     (vla-put-TextAlignmentPoint tObj (vlax-3D-point point))
     (setq BL (+ (* (strlen content) 0.1) 0.2))
     (setq P1 (polar (polar point pi (/ bl 2)) (/ pi 2) 0.125)
    p2 (polar p1 (/ (* 3 pi) 2) 0.25)
    p3 (polar (polar point 0 (/ bl 2)) (/ (* 3 pi) 2) 0.125)
    p4 (polar p3 (/ pi 2) 0.25))
     (entmakeX (list (cons 0 "LWPOLYLINE")
       (cons 100 "AcDbEntity")
       (cons 100 "AcDbPolyline")
       (cons 90 4)
       (cons 10 p1)
       (cons 10 p2)
       (cons 10 p3)
       (cons 10 p4)
       (cons 10 p1)
       (cons 70 1)
       (cons 39 0.01))))))

 

Thank you for your help, now if i can only get the dang thing to fillet as well, more points i assume.

 

Thanks again for your help,

Matt

 

Any thoughts on fillets?

Link to comment
Share on other sites

I actually have picked up on your hint and moved on, ps i the polyline closes now as well, just alittle re-arranging etc.

Thank you for your help

 

 

You're welcome. :)

 

 

Any thoughts on fillets?

 

 

"No Sir, I don't like [them]."

 

Mr__Horse_by_Ren_and_Stimpy_Club.jpg

Link to comment
Share on other sites

Hello i have updated my code:

 

(defun c:test ( / content point tobj BL p1 p2 p3 p4)
 (vl-load-com)
 
 (while (= "" (setq content (strcase (getstring t "\nContents Within Box: "))))
   (princ "\nInvalid key: Enter the contents: "))
 (if (setq point (getpoint "\nCenter of cell: "))
   (progn (setq tObj (vla-AddText
  (vlax-get-property (vla-get-ActiveDocument (vlax-get-acad-object))
    (if (= 1 (getvar 'CVPORT)) 'PaperSpace 'ModelSpace))
  content
  (vlax-3D-point point)
  0.09375))
     (vla-put-Alignment tObj acAlignmentMiddleCenter)
     (vla-put-TextAlignmentPoint tObj (vlax-3D-point point))
     (setq BL (+ (* (strlen content) 0.1) 0.2))
     (setq P1 (polar (polar point pi (/ bl 2)) (/ pi 2) 0.125)
    p2 (polar p1 (/ (* 3 pi) 2) 0.25)
    p3 (polar (polar point 0 (/ bl 2)) (/ (* 3 pi) 2) 0.125)
    p4 (polar p3 (/ pi 2) 0.25))
     (setq robj (vlax-ename->vla-object
      (entmakeX (list (cons 0 "LWPOLYLINE")
        (cons 100 "AcDbEntity")
        (cons 100 "AcDbPolyline")
        (cons 90 4)
        (cons 10 p1)
        (cons 10 p2)
        (cons 10 p3)
        (cons 10 p4)
        (cons 70 1)
        (cons 43 0.01)
        (cons 39 0.01)))))
     (vla-put-closed robj :vlax-true))))

 

Any suggestions on filleting still?

Link to comment
Share on other sites

You don't need to set it to closed with VL; (70 . 1) does that for you.

 

(defun c:test (/ content point tobj BL p1 p2 p3 p4)
 (vl-load-com)

 (while (= "" (setq content (strcase (getstring t "\nContents Within Box: "))))
   (princ "\nInvalid key: Enter the contents: ")
 )
 (setvar 'filletrad
         (cond ((getdist (strcat "\nSpecify fillet radius <"
                                 (rtos (getvar 'filletrad))
                                 ">: "
                         )
                )
               )
               ((getvar 'filletrad))
         )
 )
 (if (setq point (getpoint "\nCenter of cell: "))
   (progn (setq tObj (vla-AddText
                       (vlax-get-property
                         (vla-get-ActiveDocument (vlax-get-acad-object))
                         (if (= 1 (getvar 'CVPORT))
                           'PaperSpace
                           'ModelSpace
                         )
                       )
                       content
                       (vlax-3D-point point)
                       0.09375
                     )
          )
          (vla-put-Alignment tObj acAlignmentMiddleCenter)
          (vla-put-TextAlignmentPoint tObj (vlax-3D-point point))
          (setq BL (+ (* (strlen content) 0.1) 0.2))
          (setq P1 (polar (polar point pi (/ bl 2)) (/ pi 2) 0.125)
                p2 (polar p1 (/ (* 3 pi) 2) 0.25)
                p3 (polar (polar point 0 (/ bl 2)) (/ (* 3 pi) 2) 0.125)
                p4 (polar p3 (/ pi 2) 0.25)
          )
          (if (setq robj (entmakeX (list (cons 0 "LWPOLYLINE")
                                         (cons 100 "AcDbEntity")
                                         (cons 100 "AcDbPolyline")
                                         (cons 90 4)
                                         (cons 10 p1)
                                         (cons 10 p2)
                                         (cons 10 p3)
                                         (cons 10 p4)
                                         (cons 70 1)
                                         (cons 43 0.01)
                                         (cons 39 0.01)
                                   )
                         )
              )
            (command "_.fillet" "_polyline" robj)
          )
   )
 )
 (princ)
)

Link to comment
Share on other sites

Here it is once more with the option of square or round:

Thanks alan, i was trying to get the dang thing to round for some reason it wouldn't accept Fillet as a known command!

 

(defun c:test ( / content point tobj BL sobj robj dobj p1 p1.a p2 p3 p3.a p4)
 (vl-load-com)
 
 (while (= "" (setq content (strcase (getstring t "\nContents Within Box: "))))
   (princ "\nInvalid key: Enter the contents: "))
 (if (setq point (getpoint "\nCenter of cell: "))
    (progn (setq tObj (vla-AddText
   (vlax-get-property (vla-get-ActiveDocument (vlax-get-acad-object))
     (if (= 1 (getvar 'CVPORT)) 'PaperSpace 'ModelSpace))
   content
   (vlax-3D-point point)
   0.09375))
      (vla-put-Alignment tObj acAlignmentMiddleCenter)
      (vla-put-TextAlignmentPoint tObj (vlax-3D-point point))))
 
 (initget 128 "Square Rounded")
 (setq settings (getkword "\nChoose border type [square/Rounded]: "))
 (cond
   ((= settings "Square")
    (progn
      (setq BL (+ (* (strlen content) 0.1) 0.2))
      (setq P1 (polar (polar point pi (/ bl 2)) (/ pi 2) 0.125)
     p2 (polar p1 (/ (* 3 pi) 2) 0.25)
     p3 (polar (polar point 0 (/ bl 2)) (/ (* 3 pi) 2) 0.125)
     p4 (polar p3 (/ pi 2) 0.25))
      (entmakeX (list (cons 0 "LWPOLYLINE")
        (cons 100 "AcDbEntity")
        (cons 100 "AcDbPolyline")
        (cons 90 4)
        (cons 10 p1)
        (cons 10 p2)
        (cons 10 p3)
        (cons 10 p4)
        (cons 70 1)
        (cons 43 0.01)))))
   
    ((= settings "Rounded")
      (progn
 (setq BL (+ (* (strlen content) 0.1) 0.2))
 (setq P1 (polar (polar point pi (/ bl 2)) (/ pi 2) 0.125)
       p2 (polar p1 (/ (* 3 pi) 2) 0.25)
       p3 (polar (polar point 0 (/ bl 2)) (/ (* 3 pi) 2) 0.125)
       p4 (polar p3 (/ pi 2) 0.25))
 (setq robj (entmakeX (list (cons 0 "LWPOLYLINE")
       (cons 100 "AcDbEntity")
       (cons 100 "AcDbPolyline")
       (cons 90 4)
       (cons 10 p1)
       (cons 10 p2)
       (cons 10 p3)
       (cons 10 p4)
       (cons 70 1)
       (cons 43 0.01))))
 (command "_.fillet" "_polyline" robj))))
 (princ))

Link to comment
Share on other sites

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