BKRao Posted March 1, 2019 Posted March 1, 2019 (defun c:stno () (setq i (getint "\nEnter Start Plot No :")) ) (defun c:pno () (setq th 3) (if (= i nil) (setq i 1) ) (setvar "osmode" 0) (setq pot (getpoint "\nPick a point for Plot Boundary and No :")) (setvar "osmode" 32) (setq pt1 (getpoint "\nPick 1st Corner Point for ins :")) (setq pt3 (getcorner pt1 "\nPick Other Corner Point for ins :")) (setvar "osmode" 0) (setq ins (polar pt1 (angle pt1 pt3) (/ (distance pt1 pt3) 2))) (if (/= pot nil) (command "-BOUNDARY" pot "") ) (command "text" "j" "mc" ins th "0" i) (setq i (+ i 1)) );defun ;;; Sir I am using above lisp. I want avoid ;;;1. Pick 1st Corner Point for ins ;;;2. Pick Other Corner Point for ins ;;;- kindly guide to me Red colour rectangle is plot and yellow number is plot no. I want pick once only text always middle of plot only, if possible default no with thanks Text Mid.dwg Quote
Roy_043 Posted March 1, 2019 Posted March 1, 2019 (edited) This is a continuation of this post: https://www.cadtutor.net/forum/topic/66906-autocad-visuallisp-code-regarding/ Edited March 1, 2019 by Roy_043 Quote
ronjonp Posted March 1, 2019 Posted March 1, 2019 How about using an attributed block for this? Quote
BIGAL Posted March 2, 2019 Posted March 2, 2019 (edited) If I had 20 boxes as a block with an attribute then could just plot all of them one after the other, if the rectang block has a scale as well then that that can be used as well. Maratovich has some good plotting software for this type of question. This has been asked before here at cadtutor. Just my $0.05 I would look at layouts give up on model space title blocks. You could plot a specific layout by name using lisp automatically changing to it, like "1" Edited March 2, 2019 by BIGAL Quote
BKRao Posted March 5, 2019 Author Posted March 5, 2019 Hi, I need text not attributed block, before i was used attributed block now i want middle of rectangle point kindly help me BKRao Quote
dlanorh Posted March 5, 2019 Posted March 5, 2019 Is the rectangle already there, you just want the text in the centre? Quote
BKRao Posted March 5, 2019 Author Posted March 5, 2019 (edited) Yes sir, different size of rectangles draw before giving plot numbers. I want text centre of rectangles Edited March 5, 2019 by BKRao Quote
maratovich Posted March 5, 2019 Posted March 5, 2019 Try using this: Revers - Automatic batch printing a multiple format There is a number in the middle of the rectangle and automatic printing of the rectangles. Quote
dlanorh Posted March 5, 2019 Posted March 5, 2019 Try the attached. It incorporates the get start plot number into the lisp and will loop until a null selection is made at the "Select Plot Boundary " prompt. The text is placed into the current active layer, but this is easy to change. It makes use of the GetBoundingBox method to retrieve the lower left and upper right extents, then calculates the mid point. This should work whatever the orientation of the rectangle. plot-nos.lsp Quote
rlx Posted March 5, 2019 Posted March 5, 2019 must admit I have a little difficulty to understand what it is exactly that OP wants , place a text in the center of a poly or find one... ; place a string in center of (all) poly's (defun c:t1 ( / a sp ss i ts o l r pt to) (setq a (vla-get-activedocument (vlax-get-acad-object)) sp (vla-get-block (vla-get-activelayout a))) (prompt "\nSelect polylines to number :") (if (setq ss (ssget)) (progn (setq i 0 ts (/ (getvar 'viewsize) 50) ss (vla-get-activeselectionset a)) (vlax-for o ss (if (= (vlax-get-property o 'ObjectName) "AcDbPolyline") (progn (vla-getboundingbox o 'l 'r) (setq pt (mapcar '/ (mapcar '+ (vlax-safearray->list l) (vlax-safearray->list r)) '(2 2 2))) (setq to (vla-AddText sp (itoa (setq i (1+ i))) (vlax-3d-point pt) ts)) (vla-put-Alignment to acAlignmentRight) (vla-put-textalignmentpoint to (vlax-3d-point pt)) (vla-put-Alignment to acAlignmentMiddle) ) ) ) ) ) (vla-Regen a acActiveViewport) (princ) ) ; finding a string in center of (all) poly's (defun c:t2 ( / ss o l r sel lst) (if (setq ss (ssget "x" '((0 . "LWPOLYLINE")))) (vlax-for o (vla-get-activeselectionset (vla-get-activedocument (vlax-get-acad-object))) (vla-getboundingbox o 'r 'l) (if (setq sel (ssget "w" (setq r (vlax-safearray->list r)) (setq l (vlax-safearray->list l)) '((0 . "TEXT")))) (setq lst (cons (cons (cdr (assoc 1 (entget (ssname sel 0)))) (list l r)) lst))))) (if (and (vl-consp lst) (setq plt (getstring "\nEnter plot number : ")) (assoc plt lst)) (prompt (strcat "\nPlot number " plt " : " (vl-princ-to-string (cdr (assoc plt lst))))) (prompt "\nNo plotnumber found or selected") ) (princ) ) (vl-load-com) 1 Quote
BIGAL Posted March 5, 2019 Posted March 5, 2019 Me to not sure what is going on, I think its a big sheet with little sheet blow ups. My $0.05 use fence option for picking boxes so correct order maintained. Still dont understand why not a block so much easier to do plot range. Quote
rlx Posted March 6, 2019 Posted March 6, 2019 8 hours ago, BIGAL said: Me to not sure what is going on, I think its a big sheet with little sheet blow ups. My $0.05 use fence option for picking boxes so correct order maintained. Still dont understand why not a block so much easier to do plot range. I agree with you Bigal , why not use blocks or layouts. But maybe user has some historical baggage I dunno... But if OP has to use polylines I would recommend putting them in a special layer so selecting them would be easier by including layer name in selection filter. anyways , another code that also sorts the polylines (untested of course since we have no sample to test it on) (defun c:t4 ( / a sp i ss to p) (setq a (vla-get-activedocument (vlax-get-acad-object)) sp (vla-get-block (vla-get-activelayout a)) i 0) (prompt "\nSelect polylines to number :") (if (setq ss (ssget ":L" '((0 . "LWPOLYLINE")))) (foreach p (vl-sort (mapcar '(lambda (x) (GetBcent x)) (setq ss (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss))))) '(lambda (a b)(if (equal (cadr a) (cadr b) 1e-8) (< (car a) (car b)) (> (cadr a) (cadr b))))) (setq to (vla-AddText sp (itoa (setq i (1+ i))) (vlax-3d-point p) (/ (getvar 'viewsize) 50))) (vla-put-Alignment to acAlignmentRight)(vla-put-textalignmentpoint to (vlax-3d-point p))(vla-put-Alignment to acAlignmentMiddle) ) ) (vla-Regen a acActiveViewport) (princ) ) ; get boundingbox center (defun GetBcent ( %e / ll ur) (if (= (type %e) 'ENAME)(setq %e (vlax-ename->vla-object %e))) (cond ; get the centerpoint from boundingbox ((and (vlax-method-applicable-p %e 'getboundingbox) (not (vl-catch-all-error-p (vl-catch-all-apply 'vla-getboundingbox (list %e 'll 'ur))))) (mapcar (function (lambda (a b) (/ (+ a b) 2.)))(vlax-safearray->list ll)(vlax-safearray->list ur))) ; else get alignment or point ((and (vlax-method-applicable-p %e 'alignment)(= (vla-get-alignment %e) 1)) (reverse (cdr (reverse (vlax-safearray->list (vlax-variant-value (vla-get-TextAlignmentPoint %e))))))) (t (reverse (cdr (reverse (vlax-safearray->list (vlax-variant-value (vla-get-InsertionPoint %e))))))) ) ) 1 Quote
BKRao Posted March 7, 2019 Author Posted March 7, 2019 On 05/03/2019 at 22:03, dlanorh said: Try the attached. It incorporates the get start plot number into the lisp and will loop until a null selection is made at the "Select Plot Boundary " prompt. The text is placed into the current active layer, but this is easy to change. It makes use of the GetBoundingBox method to retrieve the lower left and upper right extents, then calculates the mid point. This should work whatever the orientation of the rectangle. plot-nos.lsp 1.47 kB · 5 downloads Thanking you plot-nos.lsp program is very good nearly to my requirement and I need small change in this program. 1. I want "pick" with in the plot boundary instead of "select plot boundary" 2. Usually plots are draw with "line", so again I want "Boundary" with in plot 3.Default number should be change to next plot number requesting to update above program. ones again thanking you Quote
dlanorh Posted March 7, 2019 Posted March 7, 2019 Please advise if this is not correct. 1. You want to select inside the boundary. Does this mean you want the boundary created? If so Layer/color/type for boundary. 2. You want a global counter for the plot number. Should this be for the session only or across multiple autocad sessions? Quote
rlx Posted March 7, 2019 Posted March 7, 2019 If you just post a (sample) drawing with 'this is what I have' , 'this is what I want to select or here is where I want to click' and 'this is what I want to happen' your problem / challenge would probably already have been resolved. Now everybody is still guessing. Quote
BKRao Posted March 7, 2019 Author Posted March 7, 2019 3 hours ago, dlanorh said: Please advise if this is not correct. 1. You want to select inside the boundary. Does this mean you want the boundary created? If so Layer/color/type for boundary. 2. You want a global counter for the plot number. Should this be for the session only or across multiple autocad sessions? 3 hours ago, dlanorh said: Please advise if this is not correct. 1. You want to select inside the boundary. Does this mean you want the boundary created? If so Layer/color/type for boundary. 2. You want a global counter for the plot number. Should this be for the session only or across multiple autocad sessions? 1. Yes sir, I want select inside the boundary, respective layer. 2. I am providing "Layout" plots numbers, so always plot numbers sequence numbers only. (for example 1 to 100) Please find the attachment of sample drawing "Text Mid.dwg" and run my "PlotNo.lsp" you will better understating my requirement. In my program I am "Pick one time for Plot Boundary" than "Pick two corners for text", Instead of I want select one time for Boundary and sequence Plot number. BKRao Text Mid.dwg PlotNo.lsp Quote
dlanorh Posted March 7, 2019 Posted March 7, 2019 I cannot open your drawing. I need it in AutoCAD 2010 format. I am still not sure of your requirements. Do you need the boundary to be created? Do you need the lisp to remember the last plot number across AUtoCAD sessions (A Dictionary entry in the drawing) or just when AutoCAD is running (a global variable) or both? Quote
rlx Posted March 7, 2019 Posted March 7, 2019 @dlanorh : I think I understand what OP wants. He has 2 layers , the first has color cyan with name "& Plots" and this contains the original polylines that define the plot area's. The second layer , "_IndivSubPlot" which has color 180 (like blue). I think OP wants to be able to click inside one of the 'empty' cyan polylines in layer "& Plots" and the routine then is suppost to give the next plotnumber (I would suggest registry or sentenv or something) , place a new polyline in layer "_IndivSubPlot" with the next number. This way OP can see which 'grid area' has been processed / plotted. Have saved the dwg to 2010. I assume the cyan poly's won't be empty so maybe build assoc list with all cyan polly's so point selected can be tested for inside point. Think intersec with / raycasting would be slow if many objects inside the polly's. Should be doable... Text Mid.dwg Quote
dlanorh Posted March 7, 2019 Posted March 7, 2019 2 hours ago, rlx said: @dlanorh : I think I understand what OP wants. He has 2 layers , the first has color cyan with name "& Plots" and this contains the original polylines that define the plot area's. The second layer , "_IndivSubPlot" which has color 180 (like blue). I think OP wants to be able to click inside one of the 'empty' cyan polylines in layer "& Plots" and the routine then is suppost to give the next plotnumber (I would suggest registry or sentenv or something) , place a new polyline in layer "_IndivSubPlot" with the next number. This way OP can see which 'grid area' has been processed / plotted. Have saved the dwg to 2010. I assume the cyan poly's won't be empty so maybe build assoc list with all cyan polly's so point selected can be tested for inside point. Think intersec with / raycasting would be slow if many objects inside the polly's. Should be doable.. Thanks rlx. 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.