IAcadPViewport2 code for my autocad

IAcadPViewport2 code for my autocad

stefanveurink68AXD
Advocate Advocate
1,198 Views
2 Replies
Message 1 of 3

IAcadPViewport2 code for my autocad

stefanveurink68AXD
Advocate
Advocate

Hey there, 

 

I've copied some code from the internet https://forums.augi.com/showthread.php?79882-Switching-layers-on-off-in-viewports-using-VBA it's the code in post #6, was posted there in 2008. 

 

In this post there's the term 'IAcadPViewport2' which my computer doesn't recognize. I work with Autocad 2018, got reference to "Microsoft ActiveX Data Objects 6.1 Library'. 

 

I can change the 'IAcadPViewport2' to 'IAcadPViewport1' or 'AcadPViewport', both are recognized, but then the code isn't working. So guess the problem is in the exact viewport type?

 

Next to the question on how to solve, I'd like to  know more about where I can find more information about these different types of viewport, the related ActiveX libraries, and that kind of stuff, cause I can't really find any clear information about what is what on the internet somewhere. Anyone got any good links?

 

Thanks! 

 

0 Likes
1,199 Views
2 Replies
Replies (2)
Message 2 of 3

grobnik
Collaborator
Collaborator

Hi @stefanveurink68AXD 

here below a link with on line help for Autocad 2019.

https://help.autodesk.com/view/OARX/2019/ENU/?guid=GUID-A809CD71-4655-44E2-B674-1FE200B9FE30

About viewport this shall be usually inside paperspace, referring to objects or part of drawing view inside modelspace.

For example if you have some section view or details of drawing that need to be viewed in a scale different from that used inside global drawing.

So I don't understand about your request to change layer on viewport. You should change object inside modelspace, and of course objects will change porperties into paperspace viewport too.

Concerning your code or part of it downloaded, seems that the IAcadPViewport2 is used to declare a variable structure, as Viewport object class, probably updated during product development.

During variable declaration after ....as you can click on right mouse button and find "list properties / method" receiving a list of properties or method for that variable.

 

0 Likes
Message 3 of 3

stefanveurink68AXD
Advocate
Advocate

For your information, I've got a drawing with multiple paperspace viewports in which in some paperspace viewports layers should be 'seeable' (not viewport-frozen), while they should be 'unseeable' (viewport-frozen) in other paperspace viewports. Next to that some lines should be grey in the one viewport, while their real color in other viewports. 

 

Usually i do this by setting one viewport correct, activate it, save the layerstate into the layerstatemanager, then activate another viewport and set the same layerstate, and copy it like that to the other viewports that need the same settings. 

 

However, I'm working on a drawing with over a hundred layouts, each layout containing at least 3 viewports, so would be nice if I don't have to set these layerstate all by hand. Automating it (setting the correct layerstate per viewport by evaluating the viewport size) would save a lot of time. so that's what i'm trying to achieve. 

 

for example: al viewports with a height < 100 should have layerstate "1", and all viewports with a height > 400 should be layerstate "3". The evaluating size and looping through viewports is not a problem, but I can't find out how to 'attach' a certain layerstate to a viewport. 

0 Likes