Author Topic: Viewport trans help  (Read 1277 times)

0 Members and 1 Guest are viewing this topic.

CincyJeff

  • Newt
  • Posts: 89
Viewport trans help
« on: January 25, 2017, 10:43:02 AM »
I'm trying to transform points between model space and paper space with a 2D drawing. I'm selecting blocks through a viewport, thanks to Jimmy Bergmark, and translating their insertion points so I can place identification blocks in paper space. The view in the viewport was set by restoring a named view that was created in model space. With the viewport open I use the following steps to get to paper space.

Starting block inspt
(2.0 -141.223 0.0)

(trans inspt 1 0)
(2418.51 2598.45 0.0)

(trans inspt 0 2)
(-16048.2 4466.0 19973.4)

(trans inspt 2 3)
(22.2473 11.7471 52.014)

The final point is close but not accurate. It should be (22.2421 11.7367 0.0). The named view is adding a z-value to the insertion point, but I don't know if that is affecting anything or not. The viewport data is: ((-1 . <Entity name: 558853b0>) (0 . "VIEWPORT") (5 . "242CAA33") (102 . "{ACAD_XDICTIONARY") (360 . <Entity name: 558853c0>) (102 . "}") (330 . <Entity name: 3f0ec380>) (100 . "AcDbEntity") (67 . 1) (410 . "S-101") (8 . "G-Anno-Vprt") (100 . "AcDbViewport") (10 25.3252 12.8759 0.0) (40 . 10.7233) (41 . 5.59271) (68 . 2) (69 . 4) (12 -14866.2 4899.44 0.0) (13 0.0 0.0 0.0) (14 0.0625 0.0625 0.0) (15 1.0 1.0 0.0) (16 0.0 0.0 1.0) (17 18877.9 33.7561 -19973.4) (42 . 50.0) (43 . 0.0) (44 . 0.0) (45 . 2147.6) (50 . 0.0) (51 . 6.16634) (72 . 5000) (90 . 32768) (281 . 0) (71 . 1) (74 . 0) (110 2400.06 2738.48 0.0) (111 0.993182 0.116577 0.0) (112 -0.116577 0.993182 0.0) (79 . 0) (146 . 0.0) (170 . 0) (61 . 5) (348 . <Entity name: 4d90070>) (292 . 1) (282 . 1) (141 . 0.0) (142 . 0.0) (63 . 250) (421 . 3355443))

Does anyone know what I'm doing wrong or how to transform the points with this viewport configuration?

Lee Mac

  • Seagull
  • Posts: 12914
  • London, England
Re: Viewport trans help
« Reply #1 on: January 25, 2017, 12:39:11 PM »
Try the following example:
Code - Auto/Visual Lisp: [Select]
  1. (defun c:test ( / p )
  2.     (cond
  3.         (   (= 1 (getvar 'tilemode))
  4.             (princ "\nCommand only available in Paperspace.")
  5.         )
  6.         (   (= 1 (getvar 'cvport))
  7.             (princ "\nPlease activate a viewport.")
  8.         )
  9.         (   (setq p (getpoint "\nSpecify point in viewport: "))
  10.             (entmake (list '(0 . "POINT") (cons 10 (mapcar '+ (trans (trans p 1 2) 2 3) '(0 0))) '(67 . 1)))
  11.         )
  12.     )
  13.     (princ)
  14. )

CincyJeff

  • Newt
  • Posts: 89
Re: Viewport trans help
« Reply #2 on: January 25, 2017, 01:32:56 PM »
Thanks Lee. It turns out the viewport was closed when the transformation was being performed. I found the issue with a little more debugging and after a couple of quick test I think it's working now.