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

Changing Viewport Properties

3 REPLIES 3
Reply
Message 1 of 4
mgorecki
788 Views, 3 Replies

Changing Viewport Properties

Hello,
I would like to change the CenterX, CenterY, Length, and Height of a viewport, but it will not let me use "entmod" to update the object. I wrote the code only to find out later that "entmod" doesn't work on viewports.

My LiSP routine will change the listed variables, but I cannot get it to actually update the viewport. If anyone has a way to do this, could you please let me know how?

Thanks,
Mark
Below is my code so far
(defun C:mvw ()
;Get the viewport on tab P9, then get the center, length and height
(setq vport_entity (entget (ssname (ssget "X" '((0 . "VIEWPORT")(410 . "P9"))) 0)))
(setq vport_loc_X (car (cdr (assoc 10 vport_entity))))
(setq vport_loc_Y (cadr (cdr (assoc 10 vport_entity))))
(setq vport_loc_Z (caddr (cdr (assoc 10 vport_entity))))
(setq vport_length (cdr (assoc 40 vport_entity)))

;Create the new values
(setq new_vport_X (- vport_loc_X 50.0))
(setq new_vport_loc (list new_vport_X vport_loc_Y vport_loc_Z))
(setq new_vport_length (- vport_length 50.0))
(setq vport_entity (subst (cons 10 new_vport_loc) (assoc 10 vport_entity) vport_entity))
(setq vport_entity (subst (cons 40 new_vport_length) (assoc 40 vport_entity) vport_entity))
(entmod vport_entity)
)

Thanks in advance,
Mark
3 REPLIES 3
Message 2 of 4
Ian_Bryant
in reply to: mgorecki

Hi,
you can do it using activex e.g.
{code}
(defun C:mvw ( / vport_entity vport_loc new_vport_loc
vport_width new_vport_width)
(setq vport_entity
(vlax-ename->vla-object
(ssname (ssget "X" '((0 . "VIEWPORT")(410 . "P9"))) 0)
)
)
(setq vport_loc
(vlax-safearray->list
(vlax-variant-value
(vlax-get-property vport_entity 'Center)
)
)
)
(setq new_vport_loc (mapcar '- vport_loc '(50 0 0)))
(setq vport_width (vlax-get-property vport_entity 'Width))
(setq new_vport_width (- vport_width 50.0))
(vlax-put-property vport_entity 'Center (vlax-3D-point new_vport_loc))
(vlax-put-property vport_entity 'Width new_vport_width)
(princ)
)
{code}
If you also wish to change the Height property
you can do this in a similar way to changing
the Width property.

Regards Ian
Message 3 of 4
mgorecki
in reply to: mgorecki

Hello Ian,
Thank you very much. I've been using LiSP for a long time, but have not really tried my hand at vLiSP (is that what they call it?). Anyway it'll give me a good chance to learn more about it.

Thanks again and have a great Christmas and Happy new year.
Mark
Message 4 of 4
Anonymous
in reply to: mgorecki

you can refer to mvsetup.lsp in ET.

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

Post to forums  

Autodesk Design & Make Report

”Boost