I am adapting a routine by Alan J Thompson found here for placing an outline of a paperspace viewport in modelspace.
I have added some lines for making a suitable Noplot layer with appropriate linetype, and wanted to make the lwpolyline have a thickness dependent upon the viewport scale.
My paperspace viewport scales are set for printing via Zoom - 1/50XP for example to get a 1:50 scale plot (or 0.02XP)
Having selected the relevant viewport, I wanted to be able to determine the vp scale, but am unsure how to extract this information from the viewport entity itself.
I did receive help some time in the past for a similar matter, but I'm not sure that I can use it in the same way. The routine was as follows:-
(defun xpfact ()
(- (car (trans '(1 0 0) 2 3))
(car (trans '(0 0 0) 2 3))
)
)
--
Gordon
Solved! Go to Solution.
Solved by phanaem. Go to Solution.
I've just seen in the DXF Group Codes for Viewports the comment at the bottom of the list that says:
Note The ZOOM XP factor is calculated with the following formula: group_41 / 2nd_group_1040 (or pspace_height / mspace_height).
However, although I understand what has to be accessed and the nature of the calculation, I do not know how to get hold of the '2nd_group_1040' which appears to be xdata.
What code do I need to access the second 1040 group from the list of xdata?
--
Gordon
Hi Gordon
The code from your first post is working if you are in PaperSpace. But if there are multiple viewports with different scale, I don't know for which one is returning the correct answer (something related to ActiveVieport or so).
Try this instead
(if (setq ss (ssget ":E:S" '((0 . "VIEWPORT")))) (vla-get-CustomScale (vlax-ename->vla-object (ssname ss 0))) )
maybe you could share the lisp, since I'm needing as it is to select the vieport and zoom it 1000 / 100XP.
Value 100, would be the scale that would change depending on what you need.
thanks
LinkedIn / AutoCAD Certified Professional
Si mi respuesta fue una solución para usted, por favor seleccione "Aceptar Solución", para que también sirva a otro usuarios.
Hi Edwin,
I have found the lisp that I adapted slightly , originally by Jimmy Bergmark.
I have it as vp-outline.lsp dated 18 Sept 2003 - you are lucky that I am still around and getting feeds/notifications.
Thanks for sharing the lisp. I think the code needs to be updated, because it does not work in autocad 2018. The command does not do anything.
LinkedIn / AutoCAD Certified Professional
Si mi respuesta fue una solución para usted, por favor seleccione "Aceptar Solución", para que también sirva a otro usuarios.
The command DOES work in AutoCAD 2018, but only to the use as stated in the comment section at the top.
In a Layout (!) you start the command and select a viewport; the routine then draws a polyline boundary in modelspace (!) to indicate the viewport boundary.
So for scaling and other settings this routine needs to be updated to specifically suite your needs.