Bill Tillman Posted March 12, 2012 Share Posted March 12, 2012 I'm still messing with this automated project and one of the things the users have asked me is this question. And remember, there is no user input allowed. If this is possible, it needs to be done completely by code. When the drawing is completed there are three layout tabs, each containing 11x17, 17x22 and 24x36 title block. The scale for 11x17 and 17x22 is 1:16 and the scale for the 24x36 is 1:12. The viewpoint is positioned by yours truly and I simply chose something that would kinda keep things centered. Kinda is the operative word. Because based on the dimensions the user requested for the assembly, the size of the finished drawing will change. Not the scale, we are hoping to keep those left alone however, it's understood that not every size assembly will fit in the viewports as they are presently scaled and this will be one of the only times the user will be allowed to manually adjust the drawing parameters. It won't be too hard to determine middle of a diagonal line drawn from the upper most right to the lower most left of the limits of the finished drawing. What I'd like to know is how could I place the center of that diagonal line in the center of the viewport....again, completely automated. No user input will be asked for or allowed. Quote Link to comment Share on other sites More sharing options...
BIGAL Posted March 13, 2012 Share Posted March 13, 2012 Just use the zoom C option you just need to work out the zoom factor for 1:16 etc Just make a viewport then MS then Z C use the model point picked you can do plan, left elevs, right etc thsi way. this is bits cut out not tested (setvar "tilemode" 0) (command "_.pspace") (command "_.ZOOM" "ALL") (command "_.mview" mp1 mp2) ;mp1 & mp2 is size of mview reqd (command "_.mspace") (command "zoom" "e") (setq zc (getpoint "\nPick pt in new window")) (setq sc (getstring "\nScale for this window 1: ")) (setq sc3 (strcat "1/" sc "xp")) (command "_.zoom" "_center" zc sc3) Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted March 13, 2012 Share Posted March 13, 2012 If I've understood what you are trying to achieve, collect a Selection Set of all objects in Modelspace and calculate the overall bounding box of the set. From the bounding box, you can determine the central point. Activate the viewport in the layout (ActivePViewport and MSpace Document properties), use the ZoomCenter method of the Application object to zoom to the calculated central point and set the viewport CustomScale property to the scale that you require. Done. Here is a quick demo of a 'CVP - Center Viewport' function: Quote Link to comment Share on other sites More sharing options...
BIGAL Posted March 14, 2012 Share Posted March 14, 2012 Nice one Lee a picture is more than worth 49 words Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted March 25, 2012 Share Posted March 25, 2012 How did you get on Bill? Quote Link to comment Share on other sites More sharing options...
Bill Tillman Posted March 29, 2012 Author Share Posted March 29, 2012 I haven't tried to take that part of the process any further. As I examined this point with my supervisor we had to agree that with all the different sizes of assemblies being drawn, there are just too many options. This is becoming clear with other portions of this project as well. Too many variables to try and make a one size fits all. We may visit this again but not until more modules are created to cover the other product lines. Quote Link to comment Share on other sites More sharing options...
BIGAL Posted March 30, 2012 Share Posted March 30, 2012 Maybe as your sheet size is fixed you could compare the size of the bounding box and the plot sheet size this will be some form of ratio that it would fit in a scale. eg say ratio is 55 scale 1:50 = 0-50 1:100 = 50-100 1:200 =101-200 so this would fit at 1:100 on sheet press OK. if say 237 message this outline will not fit on this sheet size and a reasonable scale do you want to use larger sheet or repick objects to fit on multiple sheets. Quote Link to comment Share on other sites More sharing options...
Bill Tillman Posted September 23, 2012 Author Share Posted September 23, 2012 I had time to finally revisit this topic and I think I have it. The code may not be elegant but it does the trick. Now if I could ask for the following assistance: 1. Presently, the code will create a new Viewport one of the six layout tabs. 2. It then sets the layer for the viewport using the (entlast) method. 3. The scale for the viewport is set. I still have to add some more code to calculate which scale will work best based on the size of the assembly chosen by the user. 4. The viewport is activated. 5. The view is zoomed using the Center method with the center being the midpoint of a diagonal line drawn between the upper right and lower left of the scope to be included in the viewport. There are two other essential items in the model space which are left out of this viewport, one being a detail which I hope to use a similar method to scale in a separate viewport, and second a Bill of Materials table which is imported as an OLE object from Excel. The BOM is placed on the last two layout tabs, one being 8-1/2 x 11 and the other 11 x 17. It is imperative to remember that this is part of an automated process...no user input is allowed. Everything must be done programatically. The next milestone I'd like to reach with this is to use the existing Viewports in lieu of creating new ones. I create new ones on each run because using the (entlast) method is the only way I've been able to select the viewport to set the scale and to then zoom in with it. Like I said, this may not be pretty but it is working. This is the code for the 8-1/2 x 11 layout tab. I will repeat this for the other three tabs which are 11x17, 17x22 and 24x36. A loop would be nice, I'm working on that now. (vl-load-com) (defun zoomit () (setvar "CTAB" "8.5x11") (command "._pspace") (command "._zoom" "a") (command "._mview" '(0.125 7.875) '(10.4375 1.28125)) (setq vp1 (entlast)) (command "._CHPROP" vp1 "" "LA" "Viewports" "") (vlax-put-property (vlax-ename->vla-object vp1) 'CustomScale (/ 1.0 30)) (setq doc (vla-get-activedocument (vlax-get-acad-object)) layouts (vla-get-Layouts doc)) ;;;ACTIVATE VIEWPORT (vla-put-ActiveSpace doc acPaperSpace) (vla-put-MSpace doc acFalse) (vl-catch-all-apply 'vlax-invoke-method (list pviewport 'Display acTrue)) (vla-put-MSpace doc acTrue) (setq _tl (polar (polar pt1 pi 20) a90 20) _br (polar (polar pt6 0 30) a270 51)) (command "._ZOOM" "C" (polar _tl (angle _tl _br) (/ (distance _tl _br) 2.)) "") (command "._pspace") (princ) ); end zoomit function Quote Link to comment Share on other sites More sharing options...
ReMark Posted September 23, 2012 Share Posted September 23, 2012 Once everything is fully automated how many CAD techs will be laid off? "No user input allowed..." What do your CAD techs do with all their spare time? Is it possible that your firm does not have any CAD techs and all the engineers are responsible for producing their own drawings and that's the reason for automating the entire process? That could be a real financial boon to your company re: keeping costs down. Quote Link to comment Share on other sites More sharing options...
Bill Tillman Posted September 24, 2012 Author Share Posted September 24, 2012 Actually this place is pretty progressive with seeking new ways to improve the production rather than replace production. I think they see the work that I do more as how to get more out of the existing workers rather than how to eliminate existing workers. The do have some loyalty at this place. And their goals are to increase sales by 14% over last year which means they will have to produce 14% more drawings than they did last year. As for what do the CAD users do with all the spare time...they produce that 14% more drawings. And as far as the ROI on my time, we have examined this really closely and the time they have saved has more than offset the hourly rate they pay for my time. Plus, they have lots of extra projects, database stuff, housekeeping (clearing old files out of the server after expiration times) that I've automated for them as well. Still I hear what you're saying but in this case, at least, they are not looking to layoff anyone. This works by allowing the designers to get away from the drudgery of producing the standard assembly drawings for their core product lines. And the goal will become to place all these processes on the web so their outside sales people can use it as well. Quote Link to comment Share on other sites More sharing options...
ReMark Posted September 24, 2012 Share Posted September 24, 2012 Sounds like a progressive company. 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.