Author Topic: Polygonal Viewports  (Read 4036 times)

0 Members and 1 Guest are viewing this topic.

SPDCad

  • Bull Frog
  • Posts: 453
Polygonal Viewports
« on: February 15, 2005, 10:36:44 AM »
I have been working with viewports lately, and I am trying to write a filter that only allows viewports. The problems is when you have a polygonal viewport AutoCAD stores the information as a LWPolyline not a viewport.  So how does one distinguish between a normal  polyline and a polygonal viewport.

I tried comparing by the DXF code as well as  the active X code and there doesn’t seem to be a difference. Although the DXF code for a Polygonal Viewport does seem to have extract code, but I am not quite sure that is what signals AutoCAD that the polygon is a viewport not a normal polyline.

Any help would be greatly appreciated.
 :)
AutoCAD 2010, w/ OpenDCL

visit: http://reachme.at/spd_designs

Jeff_M

  • King Gator
  • Posts: 4096
  • C3D user & customizer
Polygonal Viewports
« Reply #1 on: February 15, 2005, 10:46:44 AM »
When using objects as Viewports, the viewport entity is placed under the object. All objects used as VP's will have a reactor associated with it, as evidenced by this (entget) of a circle that is used as a VP:
Code: [Select]

((-1 . <Entity name: 4027be40>) (0 . "CIRCLE") (5 . "3C88") (102 . "{ACAD_REACTORS") (330 . <Entity name: 4027be50>) (102 . "}") (330 .  <Entity name: 400f86d0>) (100 . "AcDbEntity") (67 . 1) (410 . "TM Sheet") (8 . "EX-TREES") (100 . "AcDbCircle") (10 20.3365 17.5846 0.0) (40 . 1.92679) (210 0.0 0.0 1.0))

The assoc 330 between the 2 assoc 102 entries is the actual VP entity:
Code: [Select]

entget (cdr (assoc 330 p1)))
((-1 . <Entity name: 4027be50>) (0 . "VIEWPORT") (330 . <Entity name:
400f86d0>) (5 . "3C8A") (100 . "AcDbEntity") (67 . 1) (410 . "TM
Sheet").........

HTH

SMadsen

  • Guest
Polygonal Viewports
« Reply #2 on: February 15, 2005, 10:52:01 AM »
Try to trace ename's within the data.

Viewports with a clipping boundary has a hard pointer to the boundary object in a code 340. The clipping boundary itself only has a pointer to the viewport in a code 330 within a control string (102).

*beaten by Jeff*  :D

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
Polygonal Viewports
« Reply #3 on: February 15, 2005, 11:02:28 AM »
Polygonal or object viewports are actually clipping planes applied to a viewport that is invisible.

To obtain the viewport associated with a polyline, grab the DXF code 330 immediately following DXF 102 "ACAD_REACTORS". That is the entity name to the viewport the object is associated with. If you grab all of the viewports first from the drawing (i.e. (ssget "x" '((0 . "viewport"))) or something like that .. then grab the first DXF 330 following (0 . "VIEWPORT") which points to the clipping object.

If you erase the clipping plane, the viewport is erased and if you erase the viewport the clipping plane is erased.

so do you understand it now?

*edit* ... dangit .... beaten again ... well I should have refreshed my window before posting ...
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Polygonal Viewports
« Reply #4 on: February 15, 2005, 11:14:32 AM »
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Polygonal Viewports
« Reply #5 on: February 15, 2005, 11:24:08 AM »
= Modify to suit =

This will create a selection set of all non tiled viewports that are on:

Code: [Select]
(ssget "x"
    (list
       '(0  . "viewport")
        (cons 410
            (strcat
                (car (setq lst (layoutlist)))
                (apply 'strcat
                    (mapcar
                       '(lambda (x) (strcat "," x))
                        (cdr lst)
                    )
                )
            )
        )
       '(-4 . "!=")
       '(69 . 1)    ;; viewport is not paperspace
       '(-4 . "!=")
       '(68 . 0)    ;; viewport is on
    )
)

If you then need to find associated clipping boundaries, examine dxf group 340 in each viewports entity data as noted by the kindly folks above.

:)
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

SPDCad

  • Bull Frog
  • Posts: 453
Polygonal Viewports
« Reply #6 on: February 15, 2005, 11:46:19 AM »
I thought the DXF code for the reactor (ie. 330 and 102) was what signaled auotcad that it was a viewport, but I wasn't sure.

Thanks everyone.
AutoCAD 2010, w/ OpenDCL

visit: http://reachme.at/spd_designs

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Polygonal Viewports
« Reply #7 on: February 15, 2005, 11:57:34 AM »
Suits needs I have of my own right now, so thought I'd share (first pass, so let me know if you find errors):

Code: [Select]
(defun SSGetFloatingViewports ( )
    ;;  note, returns all floating viewports,
    ;;  including viewports that are not on
    (ssget "x"
        (list
           '(0  . "viewport")
            (cons 410
                (strcat
                    (car (setq lst (layoutlist)))
                    (apply 'strcat
                        (mapcar
                           '(lambda (x) (strcat "," x))
                            (cdr lst)
                        )
                    )
                )
            )
           '(-4 . "!=")
           '(69 . 1) ;; paperspace = 1, we don't want it
        )
    )
)

(defun SSGetFloatingViewportBoundaries ( / ss i pair result )
    ;;  create selection set of objects which
    ;;  are boundaries for floating viewports
    (cond
        (
            (and
                (setq ss (SSGetFloatingViewports))
                (setq result (ssadd))
            )
            (repeat (setq i (sslength ss))
                (if
                    (setq pair
                        (assoc 340
                            (entget
                                (ssname ss (setq i (1- i)))
                            )
                        )
                    )
                    (ssadd (cdr pair) result)
                )
            )
            (if (< 0 (sslength result)) result)
        )
    )
)

Edit: Renamed functions.
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

SMadsen

  • Guest
Polygonal Viewports
« Reply #8 on: February 15, 2005, 12:00:11 PM »
I agree with MP that you should grab code 340 from the viewport. If you are somehow forced to extract viewports from clipping objects you need to test code 330 before using it (it could hold anything .. well, in theory at least)

*edited* oh ^ there ya go :)

SPDCad

  • Bull Frog
  • Posts: 453
Polygonal Viewports
« Reply #9 on: February 15, 2005, 12:30:55 PM »
Will DXF code 330 exist in an entitiy data, if it is not a entity associated with a viewport?
AutoCAD 2010, w/ OpenDCL

visit: http://reachme.at/spd_designs

SMadsen

  • Guest
Polygonal Viewports
« Reply #10 on: February 15, 2005, 12:53:56 PM »
Code 330 is used for the owner of an entity so there is always at least one code 330 for a graphical entity (model- or paperspace for main entities .. blocks, dimensions etc. for subentities).

Code 330 is simply used to establish a reference to another entity which means it can be used for a variety of purposes. For example, an extension dictionary is referenced by 330 but also different forms of reactors such as the clipping reactor for boundary objects or group reactor for grouped objects.

If for example your clipping object is part of a group, it will contain two code 330's within the same pair of 102's, because they are both referencing reactors.