Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

split vport into pieces

11 REPLIES 11
SOLVED
Reply
Message 1 of 12
marlance
923 Views, 11 Replies

split vport into pieces

is it possible to split viewport into pieces using two lines as boundary?
ex. i have one rectangular vport and i want to split it into three by making two lines on both sides.

11 REPLIES 11
Message 2 of 12
dbroad
in reply to: marlance

If you mean a paper space viewport, then you should be able to use bpoly after drawing the line (twice).  Copy the viewport and clip each one to the new closed polylines.

Architect, Registered NC, VA, SC, & GA.
Message 3 of 12

sadot mo lang detaSmiley Very Happy

Message 4 of 12

english please.

 

I don't understand.

 

Hahaha...

 

smileyvery-happy:

Spoiler
 
Message 5 of 12
_Tharwat
in reply to: marlance


@rulep21 wrote:

english please.

 

I don't understand.

 

Hahaha...

 

smileyvery-happy:

Spoiler
 

Why did you mark the reply as SOLVED since that odd reply is not clear or correct at least ?

Message 6 of 12
pbejse
in reply to: marlance

I am wondering myself tharwat.

 

How is the post at #3 a solution rulep21?

 

Message 7 of 12
marlance
in reply to: pbejse

Sorry for that guys.

Actually dbroad and daneson gave me an idea on how to create this code.

It's just that daneson helped me personally with this code that's why I marked it as solution.

I'm really sorry for that. I'm just a newbie here and I haven't read yet the rules and regulation on this forum.

 

Anyway guys, here's the code for splitting viewport.

 

;;;;;;written by roldan r. ulep;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;viewport split;;;;;;;;;;;;;;;;
(defun c:vpsplit ()
(setq vp (ssget '((0 . "VIEWPORT"))))
(setq b1 (getpoint"\nPick point"))
(setq b2 (getpoint"\nPick point"))
(setq b3 (getpoint"\nPick point"))
(command "layer" "s" "G-VPORT" "")
(command "bpoly" b1 "")
(setq clip1 (entlast))
(command "bpoly" b2 "")
(setq clip2 (entlast))
(command "bpoly" b3 "")
(setq clip3 (entlast))
(command "copy" vp "" "0,0,0" "0,0,0" "")
(setq vp2 (entlast))
(command "copy" vp2 "" "0,0,0" "0,0,0" "")
(setq vp3 (entlast))
(command "vpclip" vp clip1 "")
(command "vpclip" vp2 clip2 "")
(command "vpclip" vp3 clip3 "")
(command "regen" "")
(princ)
)

 

Message 8 of 12
pbejse
in reply to: marlance


@rulep21 wrote:

Sorry for that guys.

Actually dbroad and daneson gave me an idea on how to create this code.

It's just that daneson helped me personally with this code that's why I marked it as solution.

I'm really sorry for that. I'm just a newbie here and I haven't read yet the rules and regulation on this forum.

 


Now it makes sense, too bad we arent privy to your discussion with Daneson. it would've been clearer to the rest of us.

 

FWIW Dbroads' suggestion is right on the money, I would have coded it diffrerently though. for one thing, it would'nt be limited to 3 viewports.

 

Anyhoo, Happy coding

 

Message 9 of 12
rrulep
in reply to: pbejse

Hi pbe

 

Can you modify it as per your suggestion?

I think that will be much better.

Or maybe change the bpoly method in creating boundary by selecting both lines and viewport.

 

Message 10 of 12
pbejse
in reply to: rrulep


@rrulep wrote:

Hi pbe

 

Can you modify it as per your suggestion?

I think that will be much better.

Or maybe change the bpoly method in creating boundary by selecting both lines and viewport.

 


Guess i can write a code using that approach, question is, do you still need another routine on top of what you already have? One you wrote seems to be working well for you.

Message 11 of 12
marlance
in reply to: marlance

yes it's working but i need your help to improve it.
Message 12 of 12
pbejse
in reply to: marlance


@rulep21 wrote:
yes it's working but i need your help to improve it.


Sure, no problem.

 

Heres a code using LINES as reference for number of split.  I cant say its an improvement though <Not thoroughly tested>

 

 

(defun c:vsplit	(/ _dxf	  _3p	 splitdata     vp     refline
		   opt	  e	 cp	c      box    sp     ep
		   Thisare	 el	box
		  )
;;;			pBe May2014			;;;
  (defun _dxf (d en) (cdr (assoc d (entget en))))
  (defun _3p (lst)
    (if	lst
      (cons (list (car lst) (cadr lst) (caddr lst))
	    (_3p (cdddr lst))
      )
    )
  )

  (princ "\nSelect Viewport")
  (if (and 
	(setq splitdata	nil Thisare nil
	      vp	(ssget "_:S:L" '((0 . "Viewport")))
	)
	(null (redraw (setq e (ssname vp 0)) 3))
	(princ "\nSelect Reference lines")
	(setq refline (ssget "_:L" '((0 . "LINE"))))
	(null (initget "Vertical Horizontal"))
	(setq opt (getkword "[Vertical/Horizontal]: "))
      )
    (progn
      (redraw e 4)
      (setq cp (_dxf 10 e))
      (setq c (if (eq opt "Vertical")
		car
		cadr
	      )
      )
      (vla-GetBoundingBox
	(setq e (vlax-ename->vla-object e))
	'll
	'ur
      )
      (setq box (mapcar 'vlax-safearray->list (list ll ur)))
      (repeat (setq i (sslength refline))
	(setq sp (_dxf 10 (setq el (ssname refline (setq i (1- i)))))
	      ep (_dxf 11 el)
	)
	(if (and (= (c ep) (c sp))
		 (setq bnd (vlax-invoke
			     e
			     'IntersectWith
			     (vlax-ename->vla-object el)
			     acExtendNone
			   )
		 )
	    )
	  (setq Thisare (cons el Thisare)
		splitdata (cons (_3p bnd) splitdata))
	)
	;(entdel el)
      )
      (if (setq	splitdata (vl-sort splitdata
				   '(lambda (j k)
				      (< (distance (Car box) (Car j))
					 (distance (Car box) (Car k))
				      )
				    )
			  )
	  )
	(progn
	  (foreach dat splitdata
	    (setq vpe (vlax-vla-object->ename (vla-copy e)))
	    (command "_rectang" "_non" (car box) "_non" (car dat))
	    (command "vpclip" vpe (entlast))
	    (setq box (list (cadr dat) (cadr box)))
	  )
	  (command "_rectang" "_non" (car box) "_non" (cadr box))
	  (command "vpclip" (vlax-vla-object->ename e) (entlast))
	  (foreach ent Thisare (entdel ent))
	)(princ (strcat "\n<<< No " opt " Lines selected >>>"))
      )
    )

  )(princ)
)
(vl-load-com)

 

HTH

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost