Strydaris Posted January 7 Posted January 7 Hi everyone, Was hoping someone could explain or help out with this. What I am looking to do is to select a rectangle within a block, but return the modelspace points of the selected rectangle. To my understanding I would need to use a transformation matrix to do this? I found this topic and I think this is the approach I need to take, but I am not 100% sure. I dont have any code for this made up yet as I am just in the planning stages. I know how to get the objects points within the block, just not sure how to get those points in relation to modelspace. I think it has something to do with vector normals and magnitude from the origin in relation to the insertion point of the block. But I havent done that type of math in 30 years. Quote
Lee Mac Posted January 7 Posted January 7 If you're selecting the rectangle manually, the transformation matrix can be automatically obtained from nentsel/nentselp. To offer a simple example, the following will create points at each vertex of a nested polyline: (defun c:test ( / enx mat sel ) (cond ( (not (setq sel (nentselp "\nSelect nested rectangle: ")))) ( (/= 4 (length sel)) (princ "\nSelected object is not nested.") ) ( (/= "LWPOLYLINE" (cdr (assoc 0 (setq enx (entget (car sel)))))) (princ "\nSelected object is not a polyline.") ) ( (apply '(lambda ( m v / n ) (setq n (cdr (assoc 210 enx))) (foreach x enx (if (= 10 (car x)) (entmake (list '(000 . "POINT") (cons 10 (mapcar '+ (mxv m (trans (cdr x) n 0)) v)) ) ) ) ) ) (LM:tmat->matvec (caddr sel)) ) ) ) (princ) ) (defun LM:tmat->matvec ( mat ) (apply 'mapcar (cons 'list (mapcar '(lambda ( r i ) (list (mapcar '(lambda ( v i ) v) r '(0 1 2)) (last r)) ) mat '(0 1 2) ) ) ) ) ;; Matrix x Vector - Vladimir Nesterovsky ;; Args: m - nxn matrix, v - vector in R^n (defun mxv ( m v ) (mapcar '(lambda ( r ) (apply '+ (mapcar '* r v))) m) ) (princ) Quote
Strydaris Posted January 7 Author Posted January 7 Hi Lee, Thanks for the reply Yes the idea is that the user will select the rectangle within the block. The block itself is a dynamic block that will have different sized rectangles for visibilities. What I am looking to do is to select the rectangle, get the points relative to modelspace location, then use those points to create a "view" that I can insert as a viewport on a layout tab. I was going to just use -view then window to create the view, but a colleague asked if there was a way to just select the rectangle and also maybe get some attribute data from the block that can be added to the layout / titleblock creation. Basically make it into a 1 click solution for each layout tab. So now its my next challenge. Thanks again. Quote
BIGAL Posted January 7 Posted January 7 (edited) Just a comment there is different ways to make rectangs that match a Title block at scale and then you can make layouts. In this image the layouts are created walking along a line or pline, matching the rotation of the rectang. I also have a grid like version where you copy a layout and place in a position. Draw rectangs.mp4 The other is for parts viewports select a point, scale and title block. They are not free but real cheap. Cost of a cup of coffee, as I normally have to edit to match your title blocks and test etc. Edited January 7 by BIGAL Quote
Strydaris Posted January 8 Author Posted January 8 Hi @BIGAL At my office we basically redid our setup and CAD standards. Big job making sure everyone switches over on new projects. We are a residential firm and we currently have our drawing template setup so that it can be changed to different paper sizes for the scales we typically use. We are using a dynamic block to allow for that adjustment. The block is placed in a way that the rectangles that represent the viewports are placed exactly where a layout template file would import them based on the paper size required. This is all manually done as most people in the office still use Acad 2016LT, we are slowly moving over to Acad 2025LT. Imagine a bunch of these (see image below) where the larger rectangle is the max extents of the largest paper size at 3/16" = 1'-0" or 1:75 and the smaller rectangle is the selected paper size. The difference between the "Design" option and the Working Drawing option is just the scale 3/16" vs 1/8" This works fine but the main problem I am having is the addition of extra options requested by the clients. Its too hard to account for all the additional required pages in the layout template. This is why I thought of the selection process to create the viewports and layouts. This way would make it easier for the user to just create the viewport and insert it directly to a new layout with the title block already in place. The main question I have BigAl is how is the layout page created? Your video doesnt show what is happening on that end. I also dont mind paying for something that works great. I have learned a ton from you and a few others on here that I wouldnt mind donating towards the work you've done. Quote
BIGAL Posted January 9 Posted January 9 (edited) The make layouts just simply reads all the rectangs that have been created, its step 2, you can move, rotate, delete,add another and then code matches to an existing layout and is copied to make a new layout, the rotation of the rectang is matched in the viewport. You can have as many goes as you like its not fixed to one go. You can either have all the title as blocks in the dwg or you can read a preset up layout from another master dwg. That is up to you. An important thing is the rectang displayed is the mview area not the title block. So can really see what it will look like on a sheet. Then don't need to do extra point calculations. Yes the make mview takes advantage of a trans function. I could make it just make one rectang at a time so can change sheet size between layouts. We only used one sheet size. Look at image above for select scale and sheet sizes. Its code is based around a Library program I use all the time Multi getvals 2 col.lsp you only need 2 lists of scale and sheet name. Its like 3 lines of code to make the dcl. Have a go for your self, examples at top of code. A ps have lots of other stuff once the make layouts is run, copy title block details to all layouts, sheet numbers, dwg index and so on. Need multi clients titles, the getvals supports up to about 20 items or could be a list so could exceed the 20, another alternative which is part of an existing client request is select client then you only see their title blocks. Sent you a PM. Multi GETVALS 2col.lsp Edited January 9 by BIGAL Quote
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.