Jump to content

Recommended Posts

Posted

Does anyone have a lisp file that will create circle on polyline vertex?

There is an option asking dia. or radius of circle to be created, and with a layer.

It really help to identify actual shots of my surveys plotting..

Posted

Try this ...

 

(defun c:Test (/ ss di la)
 ;;; Tharwat 14. Nov. 2012   ;;;
 (if (and (setq ss (ssget '((0 . "*POLYLINE"))))
          (setq di (getdist "\n Specify Circle Radius :"))
          (not (eq (setq la (getstring t "\n Enter Layer name :")) ""))
          (tblsearch "LAYER" la)
     )
   ((lambda (x / e)
      (while (setq e (ssname ss (setq x (1+ x))))
        (foreach dxf (entget e)
          (if (eq (car dxf) 10)
            (entmakex (list '(0 . "CIRCLE") dxf (cons 40 di) (cons 8 la)))
          ) ) )
    )
     -1
   )
   (princ)
 )
 (princ)
)

Posted

Very good program!!

 

If possible, can you make this:

"Specify Radius Circle: " into

"Specify Diameter of Circle [Radius]: "

 

Then write (dtext) number beside the circle having distance from center of a

circle 1.5x of the circle radius. And that number is the same to the vertex number.

 

Big Thnax!!

 

Notview

Posted

This ... ?

(defun c:Test (/ la ss)
;;; Tharwat 20. Nov. 2012   ;;;
 (if (and (setq *r* (cond ((getdist (strcat "\n Specify Diameter of Circle [Radius]"
                                            (if *r*
                                              (strcat "< " (rtos *r* 2 2) " > :")
                                              " :"
                                            )
                                    )
                           )
                          )
                          (t *r*)
                    )
          )
          (not (eq (setq la (getstring t "\n Enter Layer name :")) ""))
          (if (not (tblsearch "LAYER" la))
            (progn (princ "\n Layer Name is not found !!") nil)
            t
          )
          (setq ss (ssget '((0 . "*POLYLINE"))))
     )
   ((lambda (x / e i)
      (while (setq e (ssname ss (setq x (1+ x))))
        (setq i 0)
        (foreach dxf (entget e)
          (if (eq (car dxf) 10)
            (progn (entmakex (list '(0 . "CIRCLE") dxf (cons 40 *r*) (cons 8 la)))
                   (entmakex (list '(0 . "TEXT")
                                   (cons 1 (itoa (setq i (1+ i))))
                                   '(40 . 0.2)
                                   (cons 10 (trans (list (+ (cadr dxf) (* *r* 1.1)) (caddr dxf) 0.) 1 0))
                                   (cons 8 la)
                             )
                   )
            ) ) )  ) ) -1
   )
   (princ)
 )
 (princ)
)

Posted

I noticed after it run:

 

1. "Specify Diameter of Circle [Radius]: " ; the result was radius of circle after

it drawn.

 

2. "Specify Diameter of Circle [Radius] : " ; if I select R then

nothing happened.

Can you make: if I select R then, "Specify Radius of Circle : "

 

3. The (dtext) height of number is set at 0.20 (default).

I suggest, the number's height will be the same to diameter of circle so it looks

proportion.

 

Thanks!

 

Notview

  • 2 months later...
Posted

Tharwat, I follow your code and test it in a polyline having four vertex but what I've notice is the last number also occupies the number 1 vertex.. is it possible to do the numbering just up to 4 and not 5? in 4 vertex polyline? thanks!

Posted
Tharwat, I follow your code and test it in a polyline having four vertex but what I've notice is the last number also occupies the number 1 vertex.. is it possible to do the numbering just up to 4 and not 5? in 4 vertex polyline? thanks!

 

If you have used the command rectang to draw a square polyline , the code should work as expected , but if you use the command polyline to draw a square polyline just draw the four point and use the option close to close the square without picking the the start point once again to close the polyline .

Posted

Perhaps try something like this:

 

([color=BLUE]defun[/color] c:polycir ( [color=BLUE]/[/color] ans cnt inc lst opt sel )
   ([color=BLUE]while[/color]
       ([color=BLUE]progn[/color]
           ([color=BLUE]if[/color] ([color=BLUE]=[/color] [color=MAROON]"Diameter"[/color] opt)
               ([color=BLUE]progn[/color]
                   ([color=BLUE]initget[/color] [color=MAROON]"Radius"[/color])
                   ([color=BLUE]setq[/color] ans ([color=BLUE]getdist[/color] ([color=BLUE]strcat[/color] [color=MAROON]"\nSpecify Diameter [Radius]"[/color] ([color=BLUE]if[/color] *rad* ([color=BLUE]strcat[/color] [color=MAROON]" <"[/color] ([color=BLUE]rtos[/color] ([color=BLUE]*[/color] 2.0 *rad*)) [color=MAROON]">: "[/color]) [color=MAROON]": "[/color]))))
               )
               ([color=BLUE]progn[/color]
                   ([color=BLUE]initget[/color] [color=MAROON]"Diameter"[/color])
                   ([color=BLUE]setq[/color] ans ([color=BLUE]getdist[/color] ([color=BLUE]strcat[/color] [color=MAROON]"\nSpecify Radius [Diameter]"[/color] ([color=BLUE]if[/color] *rad* ([color=BLUE]strcat[/color] [color=MAROON]" <"[/color] ([color=BLUE]rtos[/color] *rad*) [color=MAROON]">: "[/color]) [color=MAROON]": "[/color]))))
               )
           )
           ([color=BLUE]cond[/color]
               (   ([color=BLUE]null[/color] ans)
                   ([color=BLUE]setq[/color] ans *rad*)
                   [color=BLUE]nil[/color]
               )
               (   ([color=BLUE]=[/color] 'str ([color=BLUE]type[/color] ans))
                   ([color=BLUE]setq[/color] opt ans)
               )
               (   ([color=BLUE]=[/color] [color=MAROON]"Diameter"[/color] opt)
                   ([color=BLUE]setq[/color]  ans ([color=BLUE]/[/color] ans 2.0)
                         *rad* ans
                   )
                   [color=BLUE]nil[/color]
               )
               (   ([color=BLUE]setq[/color] *rad* ans)
                   [color=BLUE]nil[/color]
               )
           )
       )
   )
   ([color=BLUE]if[/color] ([color=BLUE]and[/color] ([color=BLUE]numberp[/color] ans) ([color=BLUE]setq[/color] sel ([color=BLUE]ssget[/color] '((0 . [color=MAROON]"LWPOLYLINE"[/color])))))
       ([color=BLUE]repeat[/color] ([color=BLUE]setq[/color] inc ([color=BLUE]sslength[/color] sel))
           ([color=BLUE]setq[/color] cnt 0
                 lst [color=BLUE]nil[/color]
           )
           ([color=BLUE]foreach[/color] grp ([color=BLUE]entget[/color] ([color=BLUE]ssname[/color] sel ([color=BLUE]setq[/color] inc ([color=BLUE]1-[/color] inc))))
               ([color=BLUE]if[/color] ([color=BLUE]and[/color] ([color=BLUE]=[/color] 10 ([color=BLUE]car[/color] grp)) ([color=BLUE]not[/color] ([color=BLUE]member[/color] ([color=BLUE]cdr[/color] grp) lst)))
                   ([color=BLUE]progn[/color]
                       ([color=BLUE]entmake[/color] ([color=BLUE]list[/color] '(0 . [color=MAROON]"CIRCLE"[/color]) grp ([color=BLUE]cons[/color] 40 ans)))
                       ([color=BLUE]entmake[/color]
                           ([color=BLUE]list[/color]
                              '(0 . [color=MAROON]"TEXT"[/color])
                               ([color=BLUE]cons[/color] 01 ([color=BLUE]itoa[/color] ([color=BLUE]setq[/color] cnt ([color=BLUE]1+[/color] cnt))))
                               ([color=BLUE]cons[/color] 40 ans)
                               ([color=BLUE]cons[/color] 07 ([color=BLUE]getvar[/color] 'textstyle))
                               grp
                               ([color=BLUE]cons[/color] 11 ([color=BLUE]cdr[/color] grp))
                              '(72 . 1)
                              '(73 . 2)
                           )
                       )
                       ([color=BLUE]setq[/color] lst ([color=BLUE]cons[/color] ([color=BLUE]cdr[/color] grp) lst))
                   )
               )
           )
       )
   )
   ([color=BLUE]princ[/color])
)

Set the current layer before running the program (I saw no need for the extra layer prompt).

 

@Tharwat: note that your code permits selection of 2D (Heavy) or 3D Polylines, but can only process LWPolylines. ;)

Posted

 

@Tharwat: note that your code permits selection of 2D (Heavy) or 3D Polylines, but can only process LWPolylines. ;)

 

You're right Lee ,

 

I recently have noticed that the 3Dpoly 's coordinate points can not be gathered by the dxf 10 the same way like LWpolyline . :D

Posted

Thank u Lee once again, but another favor please..

1.) can u give an extra line in it that ask which is desired corner # 1 (which i would pick)

2.) the corner number should be offset from the corner of my desired distance.

 

And also to Tharwat, thanks... cheers:thumbsup:

Posted

Here is a quick modification:

 

([color=BLUE]defun[/color] c:polycir ( [color=BLUE]/[/color] ans cnt ent lst opt vtx )
   ([color=BLUE]while[/color]
       ([color=BLUE]progn[/color]
           ([color=BLUE]if[/color] ([color=BLUE]=[/color] [color=MAROON]"Diameter"[/color] opt)
               ([color=BLUE]progn[/color]
                   ([color=BLUE]initget[/color] [color=MAROON]"Radius"[/color])
                   ([color=BLUE]setq[/color] ans ([color=BLUE]getdist[/color] ([color=BLUE]strcat[/color] [color=MAROON]"\nSpecify Diameter [Radius]"[/color] ([color=BLUE]if[/color] *rad* ([color=BLUE]strcat[/color] [color=MAROON]" <"[/color] ([color=BLUE]rtos[/color] ([color=BLUE]*[/color] 2.0 *rad*)) [color=MAROON]">: "[/color]) [color=MAROON]": "[/color]))))
               )
               ([color=BLUE]progn[/color]
                   ([color=BLUE]initget[/color] [color=MAROON]"Diameter"[/color])
                   ([color=BLUE]setq[/color] ans ([color=BLUE]getdist[/color] ([color=BLUE]strcat[/color] [color=MAROON]"\nSpecify Radius [Diameter]"[/color] ([color=BLUE]if[/color] *rad* ([color=BLUE]strcat[/color] [color=MAROON]" <"[/color] ([color=BLUE]rtos[/color] *rad*) [color=MAROON]">: "[/color]) [color=MAROON]": "[/color]))))
               )
           )
           ([color=BLUE]cond[/color]
               (   ([color=BLUE]null[/color] ans)
                   ([color=BLUE]setq[/color] ans *rad*)
                   [color=BLUE]nil[/color]
               )
               (   ([color=BLUE]=[/color] 'str ([color=BLUE]type[/color] ans))
                   ([color=BLUE]setq[/color] opt ans)
               )
               (   ([color=BLUE]=[/color] [color=MAROON]"Diameter"[/color] opt)
                   ([color=BLUE]setq[/color] ans ([color=BLUE]/[/color] ans 2.0) *rad* ans)
                   [color=BLUE]nil[/color]
               )
               (   ([color=BLUE]setq[/color] *rad* ans)
                   [color=BLUE]nil[/color]
               )
           )
       )
   )
   ([color=BLUE]if[/color]
       ([color=BLUE]and[/color]
           ([color=BLUE]numberp[/color] ans)
           ([color=BLUE]setq[/color] ent ([color=BLUE]ssget[/color] [color=MAROON]"_+.:E:S"[/color] '((0 . [color=MAROON]"LWPOLYLINE"[/color]))))
           ([color=BLUE]setq[/color] vtx ([color=BLUE]getpoint[/color] [color=MAROON]"\nSpecify First Vertex: "[/color]))
       )
       ([color=BLUE]progn[/color]
           ([color=BLUE]setq[/color] ent ([color=BLUE]ssname[/color] ent 0)
                 vtx ([color=BLUE]fix[/color] ([color=BLUE]vlax-curve-getparamatpoint[/color] ent ([color=BLUE]vlax-curve-getclosestpointto[/color] ent ([color=BLUE]trans[/color] vtx 1 0))))
                 cnt 0
           )
           ([color=BLUE]foreach[/color] grp ([color=BLUE]reverse[/color] ([color=BLUE]entget[/color] ent))
               ([color=BLUE]if[/color] ([color=BLUE]and[/color] ([color=BLUE]=[/color] 10 ([color=BLUE]car[/color] grp)) ([color=BLUE]not[/color] ([color=BLUE]member[/color] ([color=BLUE]cdr[/color] grp) lst)))
                   ([color=BLUE]setq[/color] lst ([color=BLUE]cons[/color] ([color=BLUE]cdr[/color] grp) lst))
               )
           )
           ([color=BLUE]repeat[/color] vtx ([color=BLUE]setq[/color] lst ([color=BLUE]append[/color] ([color=BLUE]cdr[/color] lst) ([color=BLUE]list[/color] ([color=BLUE]car[/color] lst)))))
           ([color=BLUE]foreach[/color] pnt lst
               ([color=BLUE]entmake[/color] ([color=BLUE]list[/color] '(0 . [color=MAROON]"CIRCLE"[/color]) ([color=BLUE]cons[/color] 10 pnt) ([color=BLUE]cons[/color] 40 ans)))
               ([color=BLUE]entmake[/color]
                   ([color=BLUE]list[/color]
                      '(0 . [color=MAROON]"TEXT"[/color])
                       ([color=BLUE]cons[/color] 01 ([color=BLUE]itoa[/color] ([color=BLUE]setq[/color] cnt ([color=BLUE]1+[/color] cnt))))
                       ([color=BLUE]cons[/color] 40 ans)
                       ([color=BLUE]cons[/color] 07 ([color=BLUE]getvar[/color] 'textstyle))
                       ([color=BLUE]cons[/color] 10 pnt)
                       ([color=BLUE]cons[/color] 11 pnt)
                      '(72 . 1)
                      '(73 . 2)
                   )
               )
           )
       )
   )
   ([color=BLUE]princ[/color])
)
([color=blue]vl-load-com[/color]) ([color=BLUE]princ[/color])

Posted

Lee,

I want a little bit revision of this program, on the OUTPUT, can you make this..

1.) Write (dtext) number beside the circle having an offset distance from center of a

circle 1.5x (times) of the circle radius.

2.) And that number (writen) is the same to the polyline vertex number.

3.) The number's height will be the same to diameter of circle so it looks

proportion.

Thank you!!

  • 3 months later...
Posted

but i need a lisp for place a circle when i given a handle number. please any one can help me its urgent.

Posted
but i need a lisp for place a circle when i given a handle number. please any one can help me its urgent.

 

What do you mean ? can you give more details about your goal ?

Posted

hi,

 

actually if i given some feature handles in .CSV or Excel or Notepad. in Autocad i need circles in error layer for that particular entity handles.

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