COGO POINT LABEL ROTATE PICK 2 POINTS

COGO POINT LABEL ROTATE PICK 2 POINTS

Edward.Atchley
Contributor Contributor
878 Views
13 Replies
Message 1 of 14

COGO POINT LABEL ROTATE PICK 2 POINTS

Edward.Atchley
Contributor
Contributor

I have a lisp I found on here to match the rotation of another cogo point label. Its best I got and it saves a lot of time. However, I also have a little lisp to rotate Mtext by selecting it and picking two points. This Mtext rotate lisp populates the "rotation" property of the Mtext. I am wondering if the match cogo point label rotation lisp can be modified to populate the "Label Rotation" property of a cogo label by selecting 2 points. 

I know there is a good bit out there on this and if I remember correctly it was not possible. Its just that I am looking at this MPR.lsp file populate the "Label Rotation" property and can not keep from thinking it's right in front of my face. I do not code. I only borrow and make small changes to things. This is over my head. It would be cool to have the option to pick or match rotation if anyone has a solution possibly.

Thanks in advance.

0 Likes
Accepted solutions (1)
879 Views
13 Replies
Replies (13)
Message 2 of 14

john.uhden
Mentor
Mentor

@Edward.Atchley ,

A while back I had donated "MatchLabelRotation" and Autodesk actually mentioned it in the C3D help.

I don't recall their ever asking for permission, but I guess their policy is that anything donated belongs to them.

Anyway, the method is to manually rotate one label and then apply a "match" to other points.

John F. Uhden

0 Likes
Message 3 of 14

Edward.Atchley
Contributor
Contributor

John, yes when I was digging around, it was you and some others trying to do a select 2 points to rotate a point label and thats where I got this MPR.lsp. I understand the method and it saves me a lot of time. Thank you. What I'm wondering now/again is why cant we have the select 2 points to rotate? Your lisp actually writes to the "Label Rotation" property.

So this: (princ "\nSelect point to match the label rotation of to: ") should be this: (princ "\nSelect two points to match the label rotation to: ")

Then instead of passing the label rotation of an AECC_COGO_POINT pass the rotation selected by picking two points and define newrot here (vlax-put obj 'LabelRotation newrot) as being the rotation that was picked.

Like what torient uses to collect the angle then (setq newrot (the angle from picking two points))

 

Obviously I am proving my Lisp skills here. LOL

 

 

 

 

0 Likes
Message 4 of 14

john.uhden
Mentor
Mentor

@Edward.Atchley ,

If I recall, the label rotation property is not the same as a regular rotation value, so picking 2 points won't provide the results you would expect.  That's why I simply applied the value of the source to the selection.

Sorry, but for now, I don't care to do a research project on how the label rotation is defined.

John F. Uhden

0 Likes
Message 5 of 14

Edward.Atchley
Contributor
Contributor

John, no worries. I did an experiment. I placed some Mtext and rotated it arbitrarily. Then I opened properties of that Mtext and copied the "Rotation" value of 21d40'0". Then I tagged a Cogo Point Label and pasted that value into "Label Rotation" property and it rotated the Cogo Label to the same rotation visually aligned the same.

This is what I do not understand. If I can collect a "Rotation" value AND I can populate the "Label Rotation" in a Cogo Point with that "rotation" value then why can't this be automated relatively easily. 

 

0 Likes
Message 6 of 14

john.uhden
Mentor
Mentor

@Edward.Atchley ,

I sure hope you have proved me wrong.  If so, I would revise it to match the rotation of just about anything... line, tangent to curve, text, etc.  I figure that if you would have to pick two points you might as well use what C3D gives you, then you can match to that one.

John F. Uhden

0 Likes
Message 7 of 14

Edward.Atchley
Contributor
Contributor

John, yes anything with a "Rotation" property. That would be crazy good.

I am looking at your MPR.lsp and trying to use how you did this ----> (if (setq ss (ssget '((0 . "AECC_COGO_POINT"))))
(while (> (sslength ss) 0)
(setq obj (vlax-ename->vla-object (ssname ss 0)))
(vl-catch-all-apply
'(lambda ()
(vlax-put obj 'LabelRotation newrot)

 

and put it in the following code:

 

(defun c:RotateLabel (/ pt1 pt2 rotationAngle ent obj label)
(setq pt1 (getpoint "\nSelect first point: "))
(if pt1
(progn
(setq pt2 (getpoint pt1 "\nSelect second point: "))
(if pt2
(progn
(setq rotationAngle (angle pt1 pt2))
(setq ent (car (entsel "\n....select Points to change label rotation: ")))
(if (setq obj (vlax-ename->vla-object ent))
(progn
(setq label (vla-get-Label obj))
(vla-put-Rotation label rotationAngle)
(vla-put-Label obj label)
(vla-update obj)
(princ "\nLabel rotated successfully.")
)
(princ "\nInvalid AECC_COGO_POINT selected.")
)
)
(princ "\nNo second point selected.")
)
)
(princ "\nNo first point selected.")
)
(princ)
)

0 Likes
Message 8 of 14

Edward.Atchley
Contributor
Contributor
Accepted solution

Somehow I pieced them together.

Run this and pick two points then pick as many cogo labels as you want and they will rotate to new "Rotation".

Now that the door is open its your turn or anyone's turn, if ya like, to clean it up or combine the copy rotation lisp into this one and have it prompt to either copy from existing cogo point or select 2 points or  " to match the rotation of just about anything... line, tangent to curve, text, etc". Please share if you do.

I'm sure what I did is U G L Y but here it is. SPR "Set Point Rotation"

 

(defun c:SPR (/ pt1 pt2 rotationAngle doc ss ss2 obj obj2 newrot oldrot)
(vl-load-com)
(setq doc (vla-get-activedocument (vlax-get-acad-object)))
(vla-startundomark doc)
(setq pt1 (getpoint "\nSelect first point: "))
(if pt1
(progn
(setq pt2 (getpoint pt1 "\nSelect second point: "))
(if pt2
(progn
(setq newrot (angle pt1 pt2))
(princ "\n....select Points to change label rotation: ")
(if (setq ss (ssget '((0 . "AECC_COGO_POINT"))))
(while (> (sslength ss) 0)
(setq obj (vlax-ename->vla-object (ssname ss 0)))
(vl-catch-all-apply
'(lambda ()
(vlax-put obj 'LabelRotation newrot)
)
)
;;this will catch the error that occurs if the user selects a point with <default> or <none> as the style
(ssdel (ssname ss 0) ss)
)
)
)
(princ "\nInvalid AECC_COGO_POINT selected.")
)
)
(princ "\nNo second point selected.")
)
)
(princ "\nNo first point selected.")
)
;;this will catch the error that occurs if the user selects a point with <default> or <none> as the style
(ssdel (ssname ss 0) ss)
)
)
(vla-endundomark doc)
(princ)
)

0 Likes
Message 9 of 14

john.uhden
Mentor
Mentor

@Edward.Atchley ,

You seem to be pretty good at this stuff.  Stick around!

John F. Uhden

Message 10 of 14

Kent1Cooper
Consultant
Consultant

@Edward.Atchley wrote:

.... anything with a "Rotation" property. That would be crazy good. ....

.... or  " to match the rotation of just about anything... line, tangent to curve, text, etc". ....


Do I assume correctly that you mean anything with a "Rotation" property or a discernible direction ?  Lines don't have such a property the way things like [M]Text and Blocks do, nor curves that tangency is relevant to, but directionality can be extracted from various things that don't have such a property.  I assume you would also want to adjust angles to go the opposite way if the label needs that to aim in the more readable direction.

Kent Cooper, AIA
Message 11 of 14

john.uhden
Mentor
Mentor

@Edward.Atchley ,

Yes, "discernible direction" is a perfect term, and points on curves have tangent directions.

You take into account VIEWTWIST and things are always right side up.

And I've done it plenty... picking objects nested in a block or xref.

John F. Uhden

Message 12 of 14

Sea-Haven
Mentor
Mentor

My $0.05

 

 

 

; Rotate a CIV3D point
; By Alan H March 2019

(defun AH:CIV3DPTROT ( / ang obj )
(defun dtr (a)
(* pi (/ a 180.0))
)
;

(setq ang (dtr (getreal "\nEnter angle -ve for 2 points"))) 
(if (< ang 0)
(setq ang (angle (getpoint "\nPick1st point")(getpoint "\nPick 2nd point") ))
)
(while (setq ent (entsel "Pick CIV3D points press ESC or pick nothing to exit"))
(setq obj (vlax-ename->vla-object (car ent))) 
(vlax-put-property obj 'Rotation ang )
)
)

(AH:CIV3DPTROT)

 

 

Also, Write cogo point ht, CIV3D point edit description, CIV3D create point, Civ3d Change text style in labels, CIV3D change point style, Civ3d Change point label style.

 

0 Likes
Message 13 of 14

Kent1Cooper
Consultant
Consultant

@Kent1Cooper wrote:

@Edward.Atchley wrote:

.... anything with a "Rotation" property. That would be crazy good. ....

.... or  " to match the rotation of just about anything... line, tangent to curve, text, etc". ....


Do I assume correctly that you mean anything with a "Rotation" property or a discernible direction ?  ...  I assume you would also want to adjust angles to go the opposite way if the label needs that to aim in the more readable direction.


Try incorporating the (AOR) [Angle of Object, Rectified] function defined in the attached, to get the angle of whatever.  It doesn't include everything, but "just about anything," modified from something I use to align the Snap angle to a selected object.  Read the comments at the top.

Things it doesn't allow could be included, with some questions to answer:
For a Dimension, should it return the dimension-line angle regardless of where you pick, or the angle of whatever element you pick on [including extension lines, text if it's not aligned with the dimension line, etc.]?  For a 3D Solid, sometimes there's a discernible direction such as on straight edges, but it would have to use (angle) and therefore be projected onto the current drawing plane, so what if you pick on a vertical edge?  And I'm not sure a tangent direction can be found for an edge of one Extruded from a Spline.  Etc.

 

It is only for getting the angle.  Impose that on your COGO points as in other Messages.

Kent Cooper, AIA
Message 14 of 14

Edward.Atchley
Contributor
Contributor

Kent, after using  the SPR with the MPR I think this is all I would need. The COGO label flips itself for readability and its easy enough to strike a line across anything for a perceived rotation angle; text, tangent,  a block etc... I guess combining MPR and SPR would possibly be something to consider.

0 Likes