Jump to content

Recommended Posts

Posted

can someone please help me make a routine that puts a circle on every end of a polyline...

so if I select polylines, it will pit a 2Meter diameter circle on each ends??

 

or atleast help me make one?

Posted
can someone please help me make a routine that puts a circle on every end of a polyline...

so if I select polylines, it will pit a 2Meter diameter circle on each ends??

 

or atleast help me make one?

 

Hi for learning, search:

-entmake circle

-lwpolylines, vertex coordinates, etc..

 

or just fish,

make a block with 2.0M circle then look at

Recent thread here

Posted

This should be close

 

; add a circle to end of lines for import into the DRAINS software
; By alan H May 2018
(setq oldsnap (getvar "osmode"))
(setvar "osmode" 0)

(command "layer" "n" "PITS" "Color" 1 "PITS" "s" "PITS" "")
(setq ent (car (entsel "\nSelect drain layer: "))) 
(setq l_name (cdr (assoc 8 (entget ent))))
; (setq listlines (ssget "X" (list (cons 0 "line")(cons 8 l_name))))
;(setq listlines (ssget "X" (list (cons 0 "line,Lwpolyline")(cons 8 l_name))))
(setq listlines (ssget "X" (list (cons 0 "Lwpolyline")(cons 8 l_name))))

(setq y 0)
(repeat  (sslength listlines)
       (setq pt1 (cdr (assoc 10 (entget (ssname listlines y)))))
       (command "circle" pt1 1.0)
  (setq pt1 (cdr (assoc 11 (entget (ssname listlines y)))))
    (command "circle" pt1 1.0)
       (setq y (+ y 1))
)   ;end repeat listlineno


(setvar "osmode" oldsnap)

Posted
can someone please help me make a routine that puts a circle on every end of a polyline...

so if I select polylines, it will pit a 2Meter diameter circle on each ends??

 

or atleast help me make one?

 

Or try this, you'll need to input the circle radius once

 

;;This will work for LWPolylines 3DPolylines (incl fitted curves) Lines Splines arcs circles ellipses
;;If object is "closed" and the start point and end point are the same
;;then the two circles will be at the same point (eg full circles ellipses)
;;
;;Make a null selection on Select Line to end
;;Ron Harman  Copyright © 2014
;;
(defun c:pcircles (/ *error* c_doc ms circle_rad ent p_obj s_pt e_pt)

 (defun *error* ( msg ) 
   (if (and c_doc (= 8 (logand 8 (getvar 'UNDOCTL)))) (vla-endundomark c_doc))
   (if (not (wcmatch (strcase msg) "*BREAK*,*CANCEL*,*EXIT*")) (alert (strcat "\nOops an Error : " msg " occurred")))
   (princ)
 )

 (setq c_doc (vla-get-activedocument (vlax-get-acad-object)))
 (setq ms (vla-get-modelspace c_doc))
 
 (initget (+ 1 2 4))
 (setq circle_rad (getreal "\nEnter Radius for circles : "))
 
 (if (and c_doc (= 8 (logand 8 (getvar 'UNDOCTL)))) (vla-endundomark c_doc))
 (vla-startundomark c_doc)
 
 (while (setq ent (entsel "\nSelect Line : "))
   (if (not ent) (progn (vla-endundomark c_doc) (exit)))
   (setq p_obj (vlax-ename->vla-object (car ent))
         s_pt (vlax-curve-getStartPoint p_obj)
         e_pt (vlax-curve-getEndPoint p_obj)
   )
   (vla-addcircle ms (vlax-3d-point s_pt) circle_rad)
   (vla-addcircle ms (vlax-3d-point e_pt) circle_rad)
 )
 (princ)
)  
(princ)    
(princ "Type \"pcircles\" to run")
(princ)

Posted

Using THIS as a start, this should do what you want.

(defun c:foo (/ s tmp)
 (if (setq s (ssget '((0 . "*polyline"))))
   (foreach l (vl-remove-if 'listp (mapcar 'cadr (ssnamex s)))
     (mapcar '(lambda (x)
	 (and (not (vl-position x tmp))
	      (setq tmp (cons x tmp))
	      ;; '(40 . 1.) 1. is radius below .. change to suit
	      (entmakex (list '(0 . "circle") (cons 10 x) '(40 . 1.)))
	 )
       )
      (list (vlax-curve-getstartpoint l) (vlax-curve-getendpoint l))
     )
   )
 )
 (princ)
)
(vl-load-com)

Posted
Using THIS as a start, this should do what you want.

(defun c:foo (/ s tmp)
 (if (setq s (ssget '((0 . "*polyline"))))
   (foreach l (vl-remove-if 'listp (mapcar 'cadr (ssnamex s)))
     (mapcar '(lambda (x)
        (and (not (vl-position x tmp))
             (setq tmp (cons x tmp))
             ;; '(40 . 1.) 1. is radius below .. change to suit
             (entmakex (list '(0 . "circle") (cons 10 x) '(40 . 1.)))
        )
          )
         (list (vlax-curve-getstartpoint l) (vlax-curve-getendpoint l))
     )
   )
 )
 (princ)
)
(vl-load-com)

 

wow thanks! just what i need :)

 

Or try this, you'll need to input the circle radius once

 

;;This will work for LWPolylines 3DPolylines (incl fitted curves) Lines Splines arcs circles ellipses
;;If object is "closed" and the start point and end point are the same
;;then the two circles will be at the same point (eg full circles ellipses)
;;
;;Make a null selection on Select Line to end
;;Ron Harman  Copyright © 2014
;;
(defun c:pcircles (/ *error* c_doc ms circle_rad ent p_obj s_pt e_pt)

 (defun *error* ( msg ) 
   (if (and c_doc (= 8 (logand 8 (getvar 'UNDOCTL)))) (vla-endundomark c_doc))
   (if (not (wcmatch (strcase msg) "*BREAK*,*CANCEL*,*EXIT*")) (alert (strcat "\nOops an Error : " msg " occurred")))
   (princ)
 )

 (setq c_doc (vla-get-activedocument (vlax-get-acad-object)))
 (setq ms (vla-get-modelspace c_doc))
 
 (initget (+ 1 2 4))
 (setq circle_rad (getreal "\nEnter Radius for circles : "))
 
 (if (and c_doc (= 8 (logand 8 (getvar 'UNDOCTL)))) (vla-endundomark c_doc))
 (vla-startundomark c_doc)
 
 (while (setq ent (entsel "\nSelect Line : "))
   (if (not ent) (progn (vla-endundomark c_doc) (exit)))
   (setq p_obj (vlax-ename->vla-object (car ent))
         s_pt (vlax-curve-getStartPoint p_obj)
         e_pt (vlax-curve-getEndPoint p_obj)
   )
   (vla-addcircle ms (vlax-3d-point s_pt) circle_rad)
   (vla-addcircle ms (vlax-3d-point e_pt) circle_rad)
 )
 (princ)
)  
(princ)    
(princ "Type \"pcircles\" to run")
(princ)

 

so much code, im confused lol! but i like the idea of me having a control on the diameter because of the input part

 

This should be close

 

; add a circle to end of lines for import into the DRAINS software
; By alan H May 2018
(setq oldsnap (getvar "osmode"))
(setvar "osmode" 0)

(command "layer" "n" "PITS" "Color" 1 "PITS" "s" "PITS" "")
(setq ent (car (entsel "\nSelect drain layer: "))) 
(setq l_name (cdr (assoc 8 (entget ent))))
; (setq listlines (ssget "X" (list (cons 0 "line")(cons 8 l_name))))
;(setq listlines (ssget "X" (list (cons 0 "line,Lwpolyline")(cons 8 l_name))))
(setq listlines (ssget "X" (list (cons 0 "Lwpolyline")(cons 8 l_name))))

(setq y 0)
(repeat  (sslength listlines)
       (setq pt1 (cdr (assoc 10 (entget (ssname listlines y)))))
       (command "circle" pt1 1.0)
  (setq pt1 (cdr (assoc 11 (entget (ssname listlines y)))))
    (command "circle" pt1 1.0)
       (setq y (+ y 1))
)   ;end repeat listlineno


(setvar "osmode" oldsnap)

 

i like your code, i can understand it way easier than the others, i could use this for future reference

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