Jump to content
Ish

Match viewport angle to another viewport angle

Recommended Posts

Ish

Dear team 

Any tips or tricks to match only viewport angle.

I have 2 viewport 1 viewport have road plan and already rotate.

And 2 viewport I have only north symbol,

So I want match the only rotation angle of road plan to north symbol.

 

Thanks

Share this post


Link to post
Share on other sites
BIGAL

Here is a more than you asked for but shows the properties of a viewport you could pick north point and get angle, you may need to set angdir 1st else will possibly get wrong angle. You should be able to put twistangle not tested.

 

(command "._PSPACE")
(setq sss (ssget "_+.:E:S" (list (cons 0 "Viewport"))))
(setq cspace (cdr (assoc 69 (entget (ssname sss 0)))))

(setq obj (vlax-ename->vla-object (ssname sss 0)))


(if (= (vla-get-objectname obj)  "AcDbViewport")
(progn

(setq  cen (vlax-get obj  'Center ))
(setq ht (vlax-get obj 'Height))
(setq wid  (vlax-get obj 'Width))
(setq sc (vlax-get obj 'customscale ))
(setq ang (vlax-get obj 'TwistAngle))
))

 

I have the other rotate block to match a viewpoint angle.

  • Like 2

Share this post


Link to post
Share on other sites
Ish

Actually Sir, I have around 200 layout of road plan, in every layout view port Angle is different,

So, engineer told me show North arrow at every road plan viewport,

Don't copy North symbol in model space at every km.

Just one North symbol in model space, and make separate viewport for north at near road plan viewport corner.

 

In image inside red colour cloud is viewport of North, on layout.

Other north is in model space, that one engineer don't want.

Hope you understand my situation.

 

I need a trick or lisp that can draw/make automatically viewport with north symbol with same rotation angle of road plan viewport.

Thanks

 

IMG_20210403_184919.jpg

Share this post


Link to post
Share on other sites
Kajanthan

Hi @BIGAL

Your Lisp working well.

According @Ish requirement is here

 

(defun c:dd (/ sss obj ang ss vpo)
	(command "._PSPACE")
	(prompt "\nSelect source Viewport")
	(setq sss (ssget "_+.:E:S" (list (cons 0 "Viewport")) ))
	(setq obj (vlax-ename->vla-object (ssname sss 0)))
	(if (= (vla-get-objectname obj)  "AcDbViewport")
		(setq ang (vlax-get obj 'TwistAngle))
	)
	(prompt "\nSelect North symbol Vewport")
	(setq ss (ssget "_+.:E:S" (list (cons 0 "Viewport"))))
	(setq vpo (vlax-ename->vla-object (ssname ss 0)))
	(vlax-put-property vpo 'TwistAngle ang)
)

Original 

Original

 

 

Result 

432176208_Screenshot(35).thumb.png.8e9b628b469969b1cb8f20dedd7c5ff0.png

 

TwistAngle on Viewport.lsp

  • Like 2

Share this post


Link to post
Share on other sites
Ish
Posted (edited)

Thanks for your good reply sir,

 

I used twistable on viewport.lsp,

Working nicely but when I match viewport to north , object gone again I need to zoom and pan inside VP.

 

Sir I don't want zoom and pan inside VP.

 

Hope you understand

16177915360706506784200689730708.jpg

16177935373888257109724449692423.jpg

Edited by Ish
Modified

Share this post


Link to post
Share on other sites
ronjonp

Put your north arrows in model space then you don't have to worry about the angle.

  • Like 1
  • Thanks 1

Share this post


Link to post
Share on other sites
BIGAL

Like ronjonp do a insert say using top right cnr of viewport than can set angle correct rather than modify existing. Use cen wid ht to work out a insertion point.

Share this post


Link to post
Share on other sites
Ish
11 hours ago, ronjonp said:

Put your north arrows in model space then you don't have to worry about the angle.

Sir in model space I have many existing things,

Building, trees, temple, and survey plan , canal etc,

If I put on layout easy to move forward, up and down , that's why I need on layout.

Sir

Share this post


Link to post
Share on other sites
BIGAL

I should have said more you can read the viewport angle, get its width and ht so can work out any of the 4 corners, if you do do (command "pspace") it will make sure your in paper space. Change the block name Northn.

 

Like Ronjonp sometimes easier in model.

 


(defun c:insnorth ( / lay sss obj cen ht wid sc ang oldang )
(setq oldang (getvar 'aunits))
(setvar 'aunits 3)

(vlax-for lay (vla-get-Layouts (vla-get-activedocument (vlax-get-acad-object)))
(setq layname (vla-get-name lay))

(if (= layname "Model")
(princ)

(progn
(setvar 'ctab layname)
(command "._PSPACE")

(setq sss (ssget "X"(list (cons 0 "Viewport")(cons 410 (getvar 'ctab)))))

(setq obj (vlax-ename->vla-object (ssname sss 0)))

(if (= (vla-get-objectname obj)  "AcDbViewport")
  (progn
    (setq  cen (vlax-get obj  'Center ))
    (setq ht (vlax-get obj 'Height))
    (setq wid  (vlax-get obj 'Width))
    (setq sc (vlax-get obj 'customscale ))
    (setq ang (vlax-get obj 'TwistAngle))
  )
)

(setq pt (mapcar '+ cen  (list (/ wid 2.0) (/ ht 2.0) 0.0)))
(command "-insert" "NORTHN" pt 1.0 1.0 ang)

)
)
)
(setvar 'aunits oldang)
(princ)
)
(c:insnorth)

 

 

 

 

 

Share this post


Link to post
Share on other sites
ronjonp
17 hours ago, Ish said:

Sir in model space I have many existing things,

Building, trees, temple, and survey plan , canal etc,

If I put on layout easy to move forward, up and down , that's why I need on layout.

Sir

Here's some code I wrote a looong time ago. I added the 'name' variable at the top for your blockname. It will insert that block in the upper right corner of the viewport at the correct twistangle.

(defun c:northarrows (/ a ang msg name ss tab ur vtab)
  (if (tblobjname "block" (setq name "nameofyournortharrowblock"))
    (if	(setq ss (ssget "_X" '((0 . "VIEWPORT") (-4 . "!=") (69 . 1))))
      (progn (setq msg "")
	     (foreach vp (mapcar 'cadr (ssnamex ss))
	       (vla-getboundingbox (vlax-ename->vla-object vp) 'll 'ur)
	       (setq tab  (cdr (assoc 410 (entget vp)))
		     vtab (vla-get-layout (vlax-ename->vla-object (cdr (assoc 330 (entget vp)))))
		     ang  (cdr (assoc 51 (entget vp)))
		     ur	  (vlax-safearray->list ur)
	       )
	       (vla-insertblock (vla-get-block vtab) (vlax-3d-point ur) name 1 1 1 ang)
	       (setq msg (strcat msg
				 "\n North Arrow inserted on tab "
				 tab
				 " rotation "
				 (rtos (* (/ ang pi) 180.0) 2 2)
			 )
	       )
	     )
	     (princ msg)
      )
    )
    (alert (strcat "\nBlock definition '" name "' not found!"))
  )
  (princ)
)

 

Share this post


Link to post
Share on other sites
Kajanthan

Simple way..

Copy with Base point your North Symbol

 325144100_Screenshot(10).thumb.png.c558822473b92bf35ee972ce0150cdff.png

 

 

Double click in the viewport

1510768304_Screenshot(11).thumb.png.230d0818d3e3daf3c8c86b596bd3ee6e.png

 

Paste

1116526558_Screenshot(14).thumb.png.cd093ca09b68bcef307d2d4ce3f8f564.png

 

 

Click Your clear location 

1799074494_Screenshot(15).thumb.png.96a934fe39d187229725a27bea8e9393.png

 

Share this post


Link to post
Share on other sites
ronjonp
7 hours ago, Kajanthan said:

Simple way..

Copy with Base point your North Symbol

 ..

 

 

Double click in the viewport

..

 

Paste

...

 

 

Click Your clear location 

...

 

Exactly :)

  • Like 1

Share this post


Link to post
Share on other sites
BIGAL

Why not add Chspace if want in Pspace but readabilty would be ok.

Share this post


Link to post
Share on other sites

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
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

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