Sideshow-Cad Posted October 21, 2015 Share Posted October 21, 2015 Hello, I am wanting to rotate multiple blocks at once, while keeping their original position to align with with a polyline(which represents a road) I have the (attached) LISP routine which enables me to rotate multiple objects at once while keeping their original location, but it requires me to enter a value for the rotation angle. All these rotation angles will be different so I would like the same thing but an option that allows me to select a polyline(not a straight line) to align to. Anyone any ideas? Thanks in advance. rotatemultiple (ROTMULT).lsp Quote Link to comment Share on other sites More sharing options...
ReMark Posted October 21, 2015 Share Posted October 21, 2015 Align multiple blocks to multiple polylines (at different angles) in one step? Sounds pretty incredible. Quote Link to comment Share on other sites More sharing options...
Sideshow-Cad Posted October 21, 2015 Author Share Posted October 21, 2015 Does not have to be 1 step but I am determined to find a quicker way than manually rotating 500+ blocks to align with 1 polyline Quote Link to comment Share on other sites More sharing options...
ReMark Posted October 21, 2015 Share Posted October 21, 2015 Only one polyline. I see. My mistake. Quote Link to comment Share on other sites More sharing options...
BIGAL Posted October 22, 2015 Share Posted October 22, 2015 Search for tangent to pline if you can find that then mystery is solved this will give correct angle. At a vertice do you do 1/2 angle or before or after ? Quote Link to comment Share on other sites More sharing options...
guran Posted October 22, 2015 Share Posted October 22, 2015 Are all these blocks placed with their insertion points on the polylines, and if so how did you put them out to begin with? If you use the Measure command there is the option "Align block with object? [Yes / No] :" Quote Link to comment Share on other sites More sharing options...
RobDraw Posted October 22, 2015 Share Posted October 22, 2015 Are all these blocks placed with their insertion points on the polylines, and if so how did you put them out to begin with? If you use the Measure command there is the option "Align block with object? [Yes / No] :" Good tip, guran. Quote Link to comment Share on other sites More sharing options...
Sideshow-Cad Posted October 22, 2015 Author Share Posted October 22, 2015 Are all these blocks placed with their insertion points on the polylines, and if so how did you put them out to begin with? If you use the Measure command there is the option "Align block with object? [Yes / No] :" No they are not. These blocks are representing highway assets. I received a topographical survey with the location of all these highway assets. The problem is, they weren't blocks orignally. They were just polylines. I used a LISP command to convert these polylines into blocks and keep their original position. But they are all aligned due north at the moment which I do not want. I want them aligned with the curvature of the road. I have produced a polyline centreline along this road which I want to align the blocks with. But there are nearly 1,000 of them. Aligning them all manually would take a considerable amount of time I was hoping a LISP command could help. I cannot use measure/divide because they do not sit on the polyline, and they are all in their exact position. Measure/divide requires to input a specific distance/or number to plot. Hope this is clear^^ Thanks. Quote Link to comment Share on other sites More sharing options...
RobDraw Posted October 22, 2015 Share Posted October 22, 2015 No they are not. These blocks are representing highway assets. I received a topographical survey with the location of all these highway assets. The problem is, they weren't blocks orignally. They were just polylines. I used a LISP command to convert these polylines into blocks and keep their original position. But they are all aligned due north at the moment which I do not want. I want them aligned with the curvature of the road. How were the assets oriented to begin with? Was this north alignment a result of the LISP? Quote Link to comment Share on other sites More sharing options...
Sideshow-Cad Posted October 22, 2015 Author Share Posted October 22, 2015 How were the assets oriented to begin with? Was this north alignment a result of the LISP? Yes it will have been. Because they were originally poly lines and therefore had no "rotation" property set. The lisp then turned all these poly lines into individual blocks with their rotation property set as "0". I then replaced these blocks(as they look scruffy because they were just scraggly poly lines) with proper fit for purpose blocks I created. However, upon doing so, the blocks were obviously placed at rotation 0 (ie facing due north) Thanks. Quote Link to comment Share on other sites More sharing options...
RobDraw Posted October 22, 2015 Share Posted October 22, 2015 It seems that your automation has created more work for you than if you had done it manually. If you could show us what you are starting with and what the desired end result is, someone might be able to suggest a better methodology. Quote Link to comment Share on other sites More sharing options...
Sideshow-Cad Posted October 22, 2015 Author Share Posted October 22, 2015 It seems that your automation has created more work for you than if you had done it manually. If you could show us what you are starting with and what the desired end result is, someone might be able to suggest a better methodology. Hmm, I am not sure manually creating, inserting and rotating that many blocks would be quicker. I have managed to create and insert the blocks at the correct locations in just a few commands, I just need to now rotate/align them. Another thing worth mentioning is that each block has text next to it representing topography levels and the text is aligned to how I would like the corresponding block to be aligned. So if there were a way to match the rotation of the block to that of the text, that would also work. ( I would have to do this individually i presume still, but at least it would just be 1 command and then click and repeat on each of the blocks, and it would automatically rotate the blocks to the desired rotation value) I have a LISP command to match the rotation of a block to that of another block but not text. Please see my other thread I made today asking for help editing that LISP command lol. Thanks, in advance. Quote Link to comment Share on other sites More sharing options...
RobDraw Posted October 22, 2015 Share Posted October 22, 2015 Hmm, I am not sure manually creating, inserting and rotating that many blocks would be quicker. I'm not sure either. When you say blocks, I am assuming that you have many instances of each. Once one is created, the rest is easy. Without more specific information that is all I have to offer. Quote Link to comment Share on other sites More sharing options...
BIGAL Posted October 23, 2015 Share Posted October 23, 2015 Just thought of the answer to draw at 90. Chainage label a pline. There are lots out there and I know they always right text at 90 degrees. Now where did I down load it to. found one not sure if it works but it mentions using blocks for text. ; lables pline chainages (defun div-error (msg) (if (vl-position msg '("console break" "Function cancelled" "quit / exit abort" ) ) (princ "Error!") (princ msg) ) (while (> (getvar "cmdactive") 0) (command)) ;;; (command "._undo" "_end") ;;; (command "._u") (setq *error* olderror) (princ) ) (defun divplus (len segm / num lst) (setq num (fix (/ len segm))) (setq cnt 0) (while (<= cnt num) (setq tmp (* cnt segm)) (setq lst (append lst (list tmp))) (setq cnt (1+ cnt)) ) (setq delta (- len (last lst))) (if (not (zerop delta)) (setq lst (append lst (list (+ (last lst) delta)))) lst ) ) (defun divminus (len segm / lst) (while (>= len 0.) (setq lst (append lst (list len))) (setq len (- len segm)) ) (if (not (zerop (last lst))) (setq lst (append lst (list 0.0))) ) lst ) (defun alg-ang (obj pnt) (angle '(0. 0. 0.) (vlax-curve-getfirstderiv obj (vlax-curve-getparamatpoint obj pnt ) ) ) ) (defun answer (quest / wshl ans) (or (vl-load-com)) (setq wshl (vlax-get-or-create-object "WScript.Shell")) (setq ans (vlax-invoke-method wshl 'Popup quest 7 "Answer This Question:" vlax-vbYesNo)) (vlax-release-object wshl) (cond ((= ans 6) (setq opt T)) ((= ans 7) (setq opt nil)) ) opt ) (defun make-station (bname / acsp adoc atprom attag at_obj blk_obj hgt lay line_obj sfar ) (vl-load-com) (setq adoc (vla-get-activedocument (vlax-get-acad-object) ) ) (if (and (= (getvar "tilemode") 0) (= (getvar "cvport") 1) ) (setq acsp (vla-get-paperspace adoc)) (setq acsp (vla-get-modelspace adoc)) ) (vla-startundomark adoc) (if (not (tblsearch "block" bname)) (progn (setq attag "NUMBER" ;(strcase (getstring "\nAttribute tag : \n")) atprom "NUMBER" ;(strcase (getstring T "\nAttribute prompt : \n")) hgt 1.0 ;(getreal "\nAttribute text height : \n") ) (setq lay (getvar "clayer")) (setvar "clayer" "0") (setvar "attreq" 0) (setq line_obj (vlax-invoke acsp 'Addline '(0. 0. 0.) (list 0. (* hgt 12.) 0.))) (vla-put-color line_obj acyellow) (setq blk_obj (vla-add (vla-get-blocks adoc) (vlax-3d-point '(0. 0. 0.)) bname) sfar (vlax-safearray-fill (vlax-make-safearray vlax-vbObject '(0 . 0)) (list line_obj) ) ) (vla-copyobjects adoc sfar blk_obj) ;;; RetVal = object.AddAttribute(Height, Mode, Prompt, InsertionPoint, Tag, Value) (setq at_obj (vla-addattribute blk_obj hgt acattributemodeverify atprom (vlax-3d-point '(-0.5 1. 0.)) attag "0+00") ) ;;; (vla-put-alignment at_obj acAlignmentBottomCenter) ;;; (vla-put-textalignmentpoint ;;; at_obj ;;; (vlax-3d-point '(0. 1. 0.)) ;;; ) (vla-put-rotation at_obj (/ pi 2)) (vlax-release-object blk_obj) ) (progn (princ "\n\t >> Block does already exist!\n") (princ))) (if (tblsearch "block" bname) T (progn (alert "Impossible to add block"))) (setvar "attreq" 1) (setvar "clayer" lay) (vl-catch-all-apply (function (lambda ()(vla-delete line_obj)))) (vla-regen adoc acactiveviewport) (vla-endundomark adoc) (vlax-release-object acsp) (vlax-release-object adoc) (princ) ) (or (vl-load-com)) (defun C:d10 (/ *error* acsp adoc appd div-error len num olderror pl pt pt_list step util ) (or adoc (setq adoc (vla-get-activedocument (vlax-get-acad-object) ) ) ) (or appd (setq appd (vla-get-application adoc))) (or acsp (setq acsp (vla-get-block (vla-get-activelayout adoc) ) ) ) (or util (setq util (vla-get-utility adoc))) ;;; (command "._undo" "_end") ;;; (command "._undo" "_mark") (setq olderror *error*) (setq *error* div-error) ;;; (setq bname (getstring T "\nStation block name : \n")) ;;; (make-station bname) (if (not (tblsearch "block" "Station")) (make-station "Station")) (vla-getentity util 'pl 'pt "\nSelect line NEAR OF POINT TO START measure: >>> \n" ) (if pl (progn (setq step (getreal "\nEnter step for stationing <10> : \n")) (setq opt (answer "Rotate text perpendicularly to pline?")) (if (not step)(setq step 10.)) (setq len (vlax-curve-getdistatparam pl (vlax-curve-getendparam pl) ) ) (if (< (distance (vlax-safearray->list pt) (vlax-curve-getstartpoint pl) ) (distance (vlax-safearray->list pt) (vlax-curve-getendpoint pl) ) ) (setq pt_list (divplus len step)) (setq pt_list (divminus len step)) ) (setq pt_list (vl-remove-if (function not) (mapcar (function (lambda (x) (vlax-curve-getpointatdist pl x) ) ) pt_list ) ) ) (setq num 0) ;;; (setq num (getint "\nEnter initial station number\n")) (mapcar (function (lambda (x / dr ang att_list at blk_obj) (progn (setq ang (alg-ang pl x) ang (cond ((< (/ pi 2) ang (* pi 1.5)) (+ pi ang)) (T ang) ) ) (setq blk_obj (vlax-invoke acsp 'Insertblock x "Station" 1 1 1 ang) ) (setq att_list (vlax-invoke blk_obj 'Getattributes)) (foreach at att_list (if (eq (vlax-get at 'Tagstring) "NUMBER") (progn (vlax-put at 'Textstring (if (< num 990.) (strcat "sta: 0+" (rtos num 2 2)) (strcat "sta: " (itoa (fix (/ num 1000.)));<--- changes 1200. on num (typo) "+" (rtos (- num (* (fix (/ num 1000.)) 1000)) 2 2) ) )) (if (not opt) (vlax-put at 'Rotation 0)) (vla-update at) ) ) ) (vla-update blk_obj) (vlax-release-object blk_obj) (setq num (+ num step)) ) ) ) pt_list ) (if (not (vlax-object-released-p pl)) (vlax-release-object pl) ) ) (princ "\nNothing selected try again\n") ) (vla-zoomextents appd) (vla-regen adoc acactiveviewport) (setq *error* olderror div-error nil ) ;;; (command "._undo" "_end") (princ) ) (prompt "\n") (prompt "\n *** Type D10 to execute *** \n") (princ) Quote Link to comment Share on other sites More sharing options...
Fahmadzade Posted January 11, 2017 Share Posted January 11, 2017 I have a problem such as this, but with a deference that I don't know the rotation angle... I want to rotate several blocks, with different angle... In fact, I have thousands of different blocks, on polyline. I want to rotate them align their polylines... :cry: 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.