Jump to content

Recommended Posts

Posted

Hi, all

 I need ur help.

I found code in internet to draw polyline between blocks as attachment but not working properly, can any one adjust the code

thanks for cooperation

(defun c:connect (/ ss i e plist p nextpt plist-sorted rtn pp)
  (while (or (prompt "\nSelect blocks or circles...")
	     (not (setq ss (ssget '((0 . "INSERT,CIRCLE")))))
	 )
    (prompt "\nEmpty sel. set...")
  )
  (repeat (setq i (sslength ss))
    (setq e (ssname ss (setq i (1- i))))
    (setq plist (cons (cdr (assoc 10 (entget e))) plist))
  )
  (setq	p (getpoint
	    "\nPick or specify start point - use osnap cen or ins : "
	  )
  )

  (defun nextpt	(p plist / car-sort pp)

    (defun car-sort (l f / removenth r k)

      (defun removenth (l n / k)
	(setq k -1)
	(vl-remove-if '(lambda (x) (= (setq k (1+ k)) n)) l)
      )

      (setq k -1)
      (vl-some '(lambda	(a)
		  (setq k (1+ k))
		  (if (vl-every	'(lambda (x) (apply f (list a x)))
				(removenth l k)
		      )
		    (setq r a)
		  )
		)
	       l
      )
      r
    )

    (setq plist (vl-remove-if '(lambda (x) (equal x p 1e-3)) plist))
    (setq
      pp (car-sort plist
		   '(lambda (a b) (<= (distance p a) (distance p b)))
	 )
    )
    (list pp plist)
  )

  (if p
    (progn
      (while (cadr plist)
	(setq plist-sorted (cons p plist-sorted))
	(setq rtn (nextpt p plist))
	(setq pp    (car rtn)
	      plist (cadr rtn)
	)
	(setq p pp)
      )
      (setq plist-sorted (cons (car plist) plist-sorted))
      (setq plist-sorted (reverse plist-sorted))
      (entmake
	(append
	  (list
	    '(0 . "LWPOLYLINE")
	    '(100 . "AcDbEntity")
	    '(100 . "AcDbPolyline")
	    (cons 90 (length plist-sorted))
	    (cons 70
		  (if (= 1 (getvar 'plinegen))
		    128
		    0
		  )
	    )
	    '(38 . 0.0)
	  )
	  (mapcar '(lambda (p) (cons 10 p)) plist-sorted)
	  (list '(210 0.0 0.0 1.0))
	)
      )
    )
  )
  (princ)
)

 

Power wiring.dwg

Posted

Thanks mostafa for kindly reply he is good start for me, put I need it in polyline connection and with angle.
I believe is some one help me to do this task.

Posted (edited)

Your asking for a custom routine, adding the angle lines is doable, so is squaring the corner, I notice a fillet as well. You need a square on X or Y option probably a pick, pick method. A solution may be pick1st pick 2nd this implies use Y as the offset control, so when pick 4th block as per image  it knows to square line. For me a custom routine ie chargeable, I can just see lots of add this, add this. The reason I am saying to pay is you probably have more things you want done getting someone to help customise in simple terms is seconds v's minutes, just look at your  hour charge rate, you would quickly recover the cost.

 

You can move the pline cnr now using the .X & .Y method of osnap. Pick pline corner & drag up. type .Y pick block on right, need xz pick block on left, pline is now square.

Edited by BIGAL

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