SuperCAD Posted October 4, 2010 Share Posted October 4, 2010 Let me start by saying that I have NO AutoLISP programming knowledge at all. I'm having a bit of trouble getting all of my people to do a few specific things with their viewports. I've asked them numerous times to do the following: Lock all viewports Change all viewport visual styles to 2D wireframe Put all viewports on the "VIEWPORTS" layer It may be that I'm asking too much, but a couple of my guys still have unlocked viewports that won't print properly due to the visual style. They've gotten better, but a few will creep up every now and then, so I'm looking for a code that would complete the tasks I've listed above. I've tried searching for a code already but it doesn't look like one exists. Would one of you LISP guru's be so kind as to help a fellow CAD monkey out? Quote Link to comment Share on other sites More sharing options...
alanjt Posted October 4, 2010 Share Posted October 4, 2010 For the layer issue, I wrote a reactor that will place Viewports/Images/XRefs on the defined layers. Interested in that? It wouldn't be too terribly difficult to code what you want. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted October 4, 2010 Share Posted October 4, 2010 (edited) Sketched this up pretty quick, Alan, could you check the line that I marked? (defun c:test ( / doc ss vl ) (vl-load-com) (setq vl "VIEWPORTS") ;; VP Layer (setq doc (vla-get-ActiveDocument (vlax-get-acad-object))) (or (tblsearch "LAYER" vl) (vla-Add (vla-get-layers doc) vl) ) (cond ( (ssget "_X" '((0 . "VIEWPORT"))) (vlax-for vport (setq ss (vla-get-ActiveSelectionSet doc)) (vla-put-VisualStyle vport 1) (vla-put-layer vport vl) (vla-put-DisplayLocked vport :vlax-true) ) (vla-delete ss) ) ) (princ) ) vla-put-VisualStyle doesn't seem to be documented either. Edited October 4, 2010 by Lee Mac Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted October 4, 2010 Share Posted October 4, 2010 (edited) When the issue with Visual Styles is perhaps ironed out, maybe as a save reactor? (defun c:VPortFix ( / doc ss vl ) (vl-load-com) (setq vl "VIEWPORTS") ;; VP Layer (setq doc (vla-get-ActiveDocument (vlax-get-acad-object))) (or (tblsearch "LAYER" vl) (vla-Add (vla-get-layers doc) vl) ) (cond ( (ssget "_X" '((0 . "VIEWPORT"))) (vlax-for vport (setq ss (vla-get-ActiveSelectionSet doc)) (vla-put-VisualStyle vport 1) (vla-put-layer vport vl) (vla-put-DisplayLocked vport :vlax-true) ) (vla-delete ss) ) ) (princ) ) (defun c:VPortReactor nil (vl-load-com) ( (lambda ( data foo / react ) (if (setq react (vl-some (function (lambda ( reactor ) (if (eq data (vlr-data reactor)) reactor) ) ) (cdar (vlr-reactors :vlr-editor-reactor)) ) ) (if (vlr-added-p react) (vlr-remove react) (vlr-add react) ) (setq react (vlr-editor-reactor data (list (cons :vlr-beginsave foo) ) ) ) ) (princ (if (vlr-added-p react) "\n** Reactor Activated **" "\n** Reactor Deactivated **" ) ) react ) "VPort-Reactor" 'VPort-CallBack ) (princ) ) (defun VPort-CallBack ( reactor arguments ) (c:VPortFix)) (c:VPortReactor) Reactor is initiated upon loading, can be toggled off by typing "VPortReactor" Edited October 4, 2010 by Lee Mac Quote Link to comment Share on other sites More sharing options...
alanjt Posted October 4, 2010 Share Posted October 4, 2010 Works on my end. 1 is 2dwireframe and 2 is 3dhidden. Set the property, activate the viewport and type VSCurrent. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted October 4, 2010 Share Posted October 4, 2010 Works on my end. 1 is 2dwireframe and 2 is 3dhidden. Set the property, activate the viewport and type VSCurrent. Oh right - not sure what I was doing then Thanks for testing. Quote Link to comment Share on other sites More sharing options...
alanjt Posted October 4, 2010 Share Posted October 4, 2010 Oh right - not sure what I was doing then Thanks for testing. Sure thing. Quote Link to comment Share on other sites More sharing options...
alanjt Posted October 4, 2010 Share Posted October 4, 2010 If I may offer a minor enhancement, for polygonal viewports, which includes Alan's suggestion: I was only saying that for testing purposes. BTW, what are you going to do about viewports existing in a layout other that the one you occupy? Quote Link to comment Share on other sites More sharing options...
alanjt Posted October 4, 2010 Share Posted October 4, 2010 I would make this change to account for clipped viewports... (defun c:VPortFix (/ doc ss vl) (vl-load-com) (setq vl "VIEWPORTS") ;; VP Layer (setq doc (vla-get-ActiveDocument (vlax-get-acad-object))) (or (tblsearch "LAYER" vl) (vla-Add (vla-get-layers doc) vl) ) (cond ((ssget "_X" '((0 . "VIEWPORT"))) (vlax-for vport (setq ss (vla-get-ActiveSelectionSet doc)) (vla-put-VisualStyle vport 1) (vla-put-layer vport vl) (vla-put-DisplayLocked vport :vlax-true) ;; AT edit begin [color=red] (if (eq (vla-get-Clipped vport) :vlax-true) (vla-put-layer (vlax-ename->vla-object (cdr (assoc 340 (entget (vlax-vla-object->ename vport))))) vl ) )[/color] ;; AT edit end ) (vla-delete ss) ) ) (princ) ) Quote Link to comment Share on other sites More sharing options...
BlackBox Posted October 4, 2010 Share Posted October 4, 2010 (ssget "_X" '((0 . "VIEWPORT"))) BTW, what are you going to do about viewports existing in a layout other that the one you occupy? Err? (pointless text so I can post my reply) Quote Link to comment Share on other sites More sharing options...
alanjt Posted October 4, 2010 Share Posted October 4, 2010 Err? (pointless text so I can post my reply) (ssget "_X") will select everything, regardless of layout location. You would have to use the 410 variable to filter layouts. Quote Link to comment Share on other sites More sharing options...
SuperCAD Posted October 4, 2010 Author Share Posted October 4, 2010 Wow, thanks for the fast replies! It works almost perfectly. However, I do have one problem when I test it. If I set the visualstyle to anything but 2D wireframe, and then use the LISP to change it, I get this weird zoom/pan thing going on in the viewport. For example, if I zoom in with my mouse wheel the viewport will start to zoom twice as much as everything outside of the viewport, even though the viewport scale is locked. Also if I pan up or down it will zoom in when I reach the top or bottom of my screen. Quote Link to comment Share on other sites More sharing options...
BlackBox Posted October 4, 2010 Share Posted October 4, 2010 For example, if I zoom in with my mouse wheel the viewport will start to zoom twice as much as everything outside of the viewport, even though the viewport scale is locked. I hope I am not being overly critical, as I mistype things too, but for the purposes of clarity.... One cannot lock the scale, one can only set the scale, and lock the display (i.e., Display locked). Are you saying that with Display Lock = Yes, that the viewports are still zooming, etc.? Quote Link to comment Share on other sites More sharing options...
BlackBox Posted October 4, 2010 Share Posted October 4, 2010 BTW, what are you going to do about viewports existing in a layout other that the one you occupy? (ssget "_X") will select everything, regardless of layout location. You would have to use the 410 variable to filter layouts. Again, I ask... Err? Does your second response not answer your first, given (ssget "_x" '((0 . "VIEWPORT")))...? Quote Link to comment Share on other sites More sharing options...
SuperCAD Posted October 4, 2010 Author Share Posted October 4, 2010 Kind of. The veiwport is locked (VP locked, scale locked, we're debating semantics) but when I zoom in beyond a certain point, the image IN the viewport will enlarge. Also, when I pan the paperspace towards the top or bottom of the screen, the image in the viewport will again enlarge. I'm trying to do a video capture to better explain the problem. Quote Link to comment Share on other sites More sharing options...
BlackBox Posted October 4, 2010 Share Posted October 4, 2010 Kind of. The veiwport is locked (VP locked, scale locked, we're debating semantics) I don't mean to argue semantics, but assuming gets me in trouble; better to just clarify and move on. This could just be my inexperience with using Visual Styles other than 2D Wireframe (as it pertains to AutoCAD). For 3D environment modeling, I typically use Maya. I look forward to the screen capture. Quote Link to comment Share on other sites More sharing options...
SuperCAD Posted October 4, 2010 Author Share Posted October 4, 2010 Well, AutoCAD just made a liar out of me. I shut down ACAD, opened it and tried to recreate the problem but now it works just fine. Next time it happens, I'll grab a video capture of it and post it, but for now the LISP works perfectly. Thank you so much. This will help me keep my monkeys in line. Quote Link to comment Share on other sites More sharing options...
alanjt Posted October 4, 2010 Share Posted October 4, 2010 Again, I ask... Err? Does your second response not answer your first, given (ssget "_x" '((0 . "VIEWPORT")))...? Sorry, I meant your command calls. I can't reference the post since you deleted it. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted October 4, 2010 Share Posted October 4, 2010 Can't follow this thread at all Quote Link to comment Share on other sites More sharing options...
alanjt Posted October 4, 2010 Share Posted October 4, 2010 Can't follow this thread at all LoL It's become pretty congested and confusing. Did you see my post/mod about clipped viewports? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.