Visual style of active viewport in model space with lisp

Any ideas how to get it? through DXF codes? But I can't get the Viewport ID to be determined correctly.

Comments

  • Sakko
    edited December 2025

    To the best of my knowledge you cannot use the entmod function to modify a viewport entity !
    by modifying the DXF code 281 (render mode/visual style) in the viewport entity list …..

    Render Mode Values Value DXF code 281 (Render mode)
    0 2D Optimized (Classic 2D wireframe)
    1 Wireframe
    2 Hidden line
    3 Flat shaded
    4 Gouraud shaded
    5 Flat shaded with wireframe
    6 Gouraud shaded with wireframe

    : (setq vportData (entget (tblobjname "VPORT" "*ACTIVE")))
    ((-1 . <Entity name: 37e919c0>) (0 . "VPORT") (5 . "6F") (330 . <Entity name: 6b8d3180>) (100 . "AcDbSymbolTableRecord") (100 . "AcDbViewportTableRecord") (2 . "*Active") (70 . 0) (10 0.0 0.0 0.0) (11 0.320393657736 0.59083728278 0.0) (12 399.827504357857 253.38592012623 0.0) (13 0.0 0.0 0.0) (14 10.0 10.0 0.0) (15 10.0 10.0 0.0) (16 -0.491687877125855 1.19743813035916 0.56954802734165) (17 731.418796962038 498.457764863429 -221.616924238505) (40 . 280.841560210368) (41 . 1.5668449197849) (42 . 50.0) (43 . 0.0) (44 . 0.0) (50 . 0.0) (51 . 0.0) (71 . 0) (72 . 100) (73 . 1) (74 . 3) (75 . 0) (76 . 0) (77 . 0) (78 . 0) (281 . 4) (65 . 1) (110 0.0 0.0 0.0) (111 1.0 0.0 0.0) (112 0.0 1.0 0.0) (79 . 0) (146 . 0.0) (348 . <Entity name: 37e90cc0>) (60 . 3) (61 . 5) (292 . 0) (282 . 1) (141 . 0.0) (142 . 0.0) (63 . 250) (361 . <Entity name: 37e91c80>))

    ALTERNATIVELY …..

    The ActiveX interface doesn't expose a property or method to deal with the visual style of a tiled ViewPort in model space either…
    : (setq acadObj (vlax-get-acad-object)
    doc (vla-get-ActiveDocument acadObj)
    )

    : (setq vportA (vla-get-ActiveViewport doc))

    #<VLA-OBJECT IAcadViewport 000000007A4F3E10>

    : (vlax-dump-object vportA T)

    ; IAcadViewport 7a4f3e10 : TeighaX Interface of a bounded area that displays some portion of a drawing's model space
    ;
    ; Property values :
    ;
    ; Application (RO) = #<VLA-OBJECT IAcadApplication 0000000042687840>
    ; ArcSmoothness = 100
    ; Center = (399.827504357857 253.38592012623)
    ; Database (RO) = #<VLA-OBJECT IAcadDatabase 00000000A66BAD28>
    ; Direction = (-0.491687877125855 1.19743813035916 0.56954802734165)
    ; Document (RO) = #<VLA-OBJECT IAcadDocument 0000000074EB70B8>
    ; GridOn = 0
    ; Handle (RO) = "6F"
    ; HasExtensionDictionary (RO) = 0
    ; Height = 280.841560210368
    ; LowerLeftCorner (RO) = (0.0 0.0)
    ; Name = "*Active"
    ; ObjectID (RO) = 938023360
    ; ObjectID32 (RO) = 938023360
    ; ObjectName (RO) = "AcDbViewportTableRecord"
    ; OrthoOn = 0
    ; OwnerID (RO) = 1804415360
    ; OwnerID32 (RO) = 1804415360
    ; SnapBasePoint = (0.0 0.0)
    ; SnapOn = 0
    ; SnapRotationAngle = 0.0
    ; Target = (731.418796962038 498.457764863429 -221.616924238505)
    ; UCSIconAtOrigin = -1
    ; UCSIconOn = -1
    ; UpperRightCorner (RO) = (0.320393657736 0.59083728278)
    ; Width = 440.03517188008
    ;
    ; Methods supported :
    ;
    ; Delete ()
    ; Erase ()
    ; GetExtensionDictionary ()
    ; GetGridSpacing (2)
    ; GetSnapSpacing (2)
    ; GetXData (3)
    ; SetGridSpacing (2)
    ; SetSnapSpacing (2)
    ; SetView (1)
    ; SetXData (2)
    ; Split (1)

    So the best way seems to be to use the https://help.bricsys.com/en-us/document/command-reference/v/vscurrent-command?version=V26&id=165079118339
    in lisp code :
    : VSCURRENT
    Enter visual style [2dwireframe/Wireframe/Hidden/Realistic/Conceptual/Shaded/shaded with Edges/shades of Grey/SKetchy/X-ray/Other/cUrrent]: <2dWireframe>:

    (defun c:SetVPvisualStyle ( )
    ;; Directly sets the visual style of the active viewport
    (command "_.VSCURRENT" "R")
    (princ "\nViewport set to Realistic mode.")
    (princ)
    )