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

Layouts and viewport

7 REPLIES 7
SOLVED
Reply
Message 1 of 8
dicra
1319 Views, 7 Replies

Layouts and viewport

Hi everybody,

 

I'm in a problem with time, and need to find some solutions really quick. So, I would really appreciate your help.

I will have some questions about layouts and viewport. 

I need to select all the viewports in the drawing and to make some changes with them, I'm planning to select them all with ssget command. If I do that I will have one viewport for the paperspace itself in every layout. One of my question is, how to know which viewport is the paperspace itself?

Second question is, how to get the name of layout in which one is the viewport?

It is important to me that the lisp is really fast, so I'm planning to do the most of stuffs with vla commands.

 

Thank you for any help you can provide.

7 REPLIES 7
Message 2 of 8
dicra
in reply to: dicra

I was thinking something, correct me if I'm wrong.

Maybe it is better to select all the layouts with vla-get-layouts,

then I can easily get the name of every layout. 

Now I'm not sure how to get the viewport, is this the right way:

(setq layblock (vla-get-block layout))

(setq vp1 (vla-item layblock 0)) ;Is always the first one Paperspace?

(setq vp2 (vla-item layblock 1)) ; If the first one is paperspace, then this is the one I need !

 

What are more experienced lispers thinking, is this the better way, then to collect all the viewports with ssget?

 

Message 3 of 8
pendean
in reply to: dicra
Message 4 of 8
dicra
in reply to: pendean

pendean,

 

Thank you for a quick answer.

Actually that was my start before I asked my question, from that I get here where I'm now...

 

Message 5 of 8
_gile
in reply to: dicra

Hi,

 

Each Layout Viewport ID is equal to 1, foating Viewport IDs are always greater than 1, so you can use a relational test in your filter on the DXF code 69 (the viewport iD).

 

(ssget "_X" '((0 . "viewport") (-4 . ">") (69 . 1)))

 



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

Message 6 of 8
dicra
in reply to: _gile

Thank you gile,

 

It was exactly, for what I was looking for.

Now with assoc 410 I can get the name of the layout in which one is viewport created.

 

Thanks again.

 

Is there a way to get the name of the layout from viewport vla-object?

Message 7 of 8
_gile
in reply to: dicra

Assuming 'vp' is the viewport vla-object:

(vla-get-Name
  (vla-get-Layout
    (vla-ObjectIdToObject
      (vla-get-Activedocument (vlax-get-acad-object))
      (vla-get-OwnerId vp)
    )
  )
)

 



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

Message 8 of 8
dicra
in reply to: _gile

gile,

 

Thank you again, for the help.

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

Post to forums  

Autodesk Design & Make Report

”Boost