Jump to content

Divide lines into equal intervals but end side should be half of between intervals


Recommended Posts

Posted

Is there any lisp to do the following condition?

Divide lines into equal intervals but end side should be half of between intervals and add cross vertex also

line dividel.jpg

Posted

sir

i need to enter "Enter the number of segments" and also cross point "x" with point size 5

Posted (edited)

Use "divide" command with twice large number of segments and then take every odd point 1,3,5,...

 

Make sure you set "PDMODE" to 3 before "DIVIDE"...

 

M.R.

 

(defun c:divtest ( / pdm pds e ss c n )
 (setq pdm (getvar 'pdmode)
       pds (getvar 'pdsize)
 )
 (setq e (entlast))
 (if (null e)
   (progn
     (alert "No entities in active document... Please create and restart routine...")
     (exit)
   )
   (progn
     (while (not ss)
       (prompt "\nPick curve for division with points on equal spaces and half spaces at start/end of curve")
       (if (setq ss (ssget "_+.:E:S" '((0 . "*POLYLINE,LINE,SPLINE,HELIX,CIRCLE,ARC,ELLIPSE"))))
         (progn
           (setq c (ssname ss 0))
           (initget 7)
           (setq n (getint "\nSpecify number of division spaces : "))
           (setvar 'pdmode 3)
           (setvar 'pdsize 5)
           (command "_.divide" c (* (1- n) 2))
           (setq e (entnext e))
           (repeat (- n 2)
             (setq e (entnext e))
             (entdel e)
             (setq e (entnext e))
           )
         )
         (alert "Empty sel. set... Please, select again...")
       )
     )
   )
 )
 (setvar 'pdmode pdm)
 (setvar 'pdsize pds)
 (princ)
)

Edited by marko_ribar
added code
Posted
(defun c:dib (/ point e div d mark1 pd)
;;;	pBeFeb2014	;;;
 (defun Point (pt)
   (entmakex (list (cons 0 "POINT")
	    (cons 10 pt)
      )
   )
 )

 (if (and (setq
     ss	(setq
	  ss (ssget
	       '((0
		  .
		  "LWPOLYLINE,LINE,SPLINE,ARC"
		 )
		)
	     )
	)
   )
   (setq div (getint "\nEnter the number of segments : "))
     )
   (repeat (setq i (sslength ss))
     (setq e (ssname ss (setq i (1- i))))
     (setq d (vlax-curve-getdistatpoint e (vlax-curve-getEndPoint e)))
     (setq mark1 (/ d div)
    hlf	  (* 0.5 mark1)
     )
     (point (setq pd (vlax-curve-getpointatdist e hlf)))
     (repeat (1- div)
(point (setq pd	(vlax-curve-getpointatdist
		  e
		  (+ (vlax-curve-getdistatpoint e pd) mark1)
		)
       )
)
     )
   )
 )
 (princ)
)

Posted

It’s working but I have to ensure "PDMODE=3", "PDSIZE = -5" before using lisp

Posted

Then just add those statements to the code:

(setvar "PDMODE" 3)
(setvar "PDSIZE" -5)

Posted

yes its working

thank for your valuable support

Posted
yes its working

thank for your valuable support

 

Good for you akgbmb, Glad i could help :)

 

Then just add those statements to the code:

 

Yup, Thank you for that.

 

@Marko

 

Did not realize that you set & re-set the pdmode and pdsize variable, which i find really odd.

 

Guys, is there a lisp code out there that converts point entity to a series of objects (almost sure there would be) ? or is better to use a block equivalent of the point style instead?

 

Any thoughts?

Posted
Good for you akgbmb, Glad i could help :)

@Marko

 

Did not realize that you set & re-set the pdmode and pdsize variable, which i find really odd.

 

pBe, I've set pdmode to 35 and pdsize to -1.5 in my acaddoc.lsp and maybe that's also the case with OP's settings of ACAD... I've set and re-set these variables as OP wanted these values for this specific task... Only didn't know wheather OP thought on relative % size of points in relation to current viewport display or he wanted 5 dwg units size...

Posted
Guys, is there a lisp code out there that converts point entity to a series of objects (almost sure there would be) ? or is better to use a block equivalent of the point style instead?

 

Any thoughts?

 

Have you tried NodeSert lisp on the Jeffrey P Sanders website? It might be a start.

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