Cogo Point 'labelrotation

Cogo Point 'labelrotation

john.uhden
Mentor Mentor
3,515 Views
13 Replies
Message 1 of 14

Cogo Point 'labelrotation

john.uhden
Mentor
Mentor

Anyone know the relationship between an angle in modelspace and a point's 'labelrotation property?  To me they don't seem to be even close (like 106° different).

John F. Uhden

0 Likes
Accepted solutions (1)
3,516 Views
13 Replies
Replies (13)
Message 2 of 14

Jeff_M
Consultant
Consultant

Can you provide an example drawing, John? In this image, both the Point and Label have been rotated 45 degrees. Both properties are showing this correctly (in radians).

 2020-10-12_10-30-03.png

Jeff_M, also a frequent Swamper
EESignature
0 Likes
Message 3 of 14

john.uhden
Mentor
Mentor

Hi, Jeff (a person from the old days whom I always respected)

I see from your image that everything looks as it should.

Might my viewtwist be affecting the values, which were about 106° different between the 'labelrotation and the WCS angle?

Attached is an excerpt from C3D2020.  Focus on the points on the curb line.  What I am wanting to do is to rotate (align) multiple points at once using (getangle).  Gripping+rotating each one is pure tedium.

John F. Uhden

0 Likes
Message 4 of 14

Jeff_M
Consultant
Consultant

Hi John, (I can say the same regarding you! 🙂 )

It looks like a combination of things are going to affect the label rotation. Depending on the Point style setting for rotation angle and orientation reference, in combination with the PointLabel style's rotation property for the TextComponent(s), will all contribute to how the label must be rotated to be aligned.

 

In this case, the Point style is set to 0 degrees, oriented to the View. This is why the DViewTwist is affecting the outcome.

Jeff_M, also a frequent Swamper
EESignature
0 Likes
Message 5 of 14

john.uhden
Mentor
Mentor
Thanks, Jeff.
I'll check that out by changing the viewtwist, but I am positive that the
point labels that I didn't rotate manually are not orthogonal to the
twist. Either I will figure it out or determine that there's a bug in the
C3D software. Sorta just like the old days.
What drives me crazy these days is the proliferation of posts that start
with "I need." I hardly visit the C3D section, but the AutoLisp
Customization section is being treated like a freeware drive-thru. I need
a winning lottery ticket, but you don't see any needy people offering that
in return. I miss Steve Johnson and all those who were icons to me.
Though Giles Chanteaux is a damned good replacement. At least I still feel
like the underdog, gnawing away at any bone I can find to improve myself.

John F. Uhden

0 Likes
Message 6 of 14

john.uhden
Mentor
Mentor

@Jeff_M 

I am trying to get at where all the styles are via Vlisp but it seems that you can't retrieve the 'Name property of each dictionary item in the activedocument database dictionary.  Even though you can see the names when you dump them all, the 'Name property is not available.  Maybe a dictnext will work.  Or maybe AutoLisp/VLisp won't work at all.  Hmm, it could be because many of the dictionary items don't have '(300 . "<Name>") codes.
Got any ideas?
Using dictnext I found that the only item with a 300 code is "CIV3D."  So maybe I'll delve into that.

John F. Uhden

0 Likes
Message 7 of 14

john.uhden
Mentor
Mentor

Ahah!  The labelrotation IS relative to the twist angle.  Now I just have to find out where the initial labelrotation value is stored for each point style, or maybe I don't.  Later, dude, gotta get some real work done.

John F. Uhden

0 Likes
Message 8 of 14

Jeff_M
Consultant
Consultant
Accepted solution

@john.uhden , with C3D forget the Dictionary approach. Here's an example of getting to the angle for the first textcomponent in a label style (using your dwg and styles). This should help going forward.

 

(defun getaeccApp (module / *acad* C3D) ;; module must be "Land", "Pipe", "Roadway", or "Survey"
  (vl-load-com)
  (if (and (setq *acad* (vlax-get-acad-object))
	   (setq C3D (strcat "HKEY_LOCAL_MACHINE\\"
			     (if vlax-user-product-key
			       (vlax-user-product-key)
			       (vlax-product-key)
			     )
		     )
		 C3D (vl-registry-read C3D "Release")
		 C3D (substr
		       C3D
		       1
		       (vl-string-search
			 "."
			 C3D
			 (+ (vl-string-search "." C3D) 1)
		       )
		     )
		 C3D (vla-getinterfaceobject
		       (vlax-get-acad-object)
		       (strcat "AeccXUi" module ".Aecc" (if (= (strcase module) "LAND") "" module) "Application." C3D)
		     )
	   )
      )
    C3D
  )
)

(defun pointlabelstylestuff (/ C3DDOC LBLSTYL1 POINT_LABEL_STYLES TXTCOMP1 TXTCOMPS TXTROT)
  (setq c3ddoc (vlax-get (getaeccapp "Land") 'activedocument))
  (setq Point_label_styles (vlax-get c3ddoc 'PointLabelStyles))
  (setq lblstyl1 (vlax-get-property Point_label_styles 'item "Elevation Only_TC_LDC"))
  (setq txtcomps (vlax-get lblstyl1 'textcomponents))
  (setq txtcomp1 (vlax-get-property txtcomps 'item 0))
  (setq txtrot (vlax-get-property (vlax-get-property txtcomp1 'angle) 'value))
  )

 

Jeff_M, also a frequent Swamper
EESignature
Message 9 of 14

john.uhden
Mentor
Mentor

Wow, @Jeff_M 

I am presuming that will be a huge help.  Yes, the style definition is at 45°.

But the relationship between that angle and the 'labelrotation and viewtwist is eluding me as yet.  I'll work on it.

Many, many thanks!

John F. Uhden

0 Likes
Message 10 of 14

john.uhden
Mentor
Mentor

I found a simple approach that will have to be good enough for now...

Just select a source AECC_COGO_POINT (that you've already rotated to your liking), get its 'LabelRotation, and put it to a selection set.  It works.

John F. Uhden

Message 11 of 14

Jeff_M
Consultant
Consultant
Sometimes simple is good. 🙂
Jeff_M, also a frequent Swamper
EESignature
0 Likes
Message 12 of 14

john.uhden
Mentor
Mentor
I thought that I had posted a sample LabelRotation.DWG with a number of
point labels along the curb line rotated manually.

John F. Uhden

0 Likes
Message 13 of 14

john.uhden
Mentor
Mentor

@Jeff_M 

Once I add an *error* function, Undo control, and some comments, I will post it in a response as others may have use for it.  I have left it at work (which is stupid 'cause I could have put it on my flash drive or e-mailed it to myself).  Oh well, it would certainly be easy enough to recreate.  Without the *error* function it's only like 20 lines, and I usually use a separate line for each operation.

Thank goodness the 'LabelRotation property isn't ReadOnly.

John F. Uhden

0 Likes
Message 14 of 14

john.uhden
Mentor
Mentor
(defun c:MatchLabelRotation ( / *error* vars vals e obj rot ss i)
  ;; by John Uhden
  ;; v1.0 (10-14-2020)
  ;; Routine is a simply programmed means of changing the 'LabelRotation of
  ;; a selection of existing Civil 3D Cogo points simply by matching the value
  ;; taken from a selected source point.
  ;; I would prefer to just point to an angle and have it modify the points,
  ;; but I can't (yet) figure out the relationship between the 'LabelRotation
  ;; and normal AutoCAD angles.
  ;; Credit goes to Jeff Mishler (@Jeff_M) for keeping me interested when I was getting nowhere.
  ;; Plus, he gave me some important code that may be the secret to conquering
  ;; this mission.  I once conquered Land Desktop, so I'll ultimately succeed.
  (defun *error* (err)
     (mapcar 'setvar vars vals)
     (vla-endundomark *doc*)
     (cond
       ((not err))
       ((wcmatch (strcase err) "*CANCEL*,*QUIT*")
         (vl-exit-with-error "\r                                              ")
       )
       (1 (vl-exit-with-error (strcat "\r*ERROR*: " err)))
     )
     (princ)
  )
  (setq *acad* (vlax-get-acad-object)
        *doc* (vlax-get *acad* 'activedocument)
        vars '("cmdecho" "blipmode" "highlight") ;; not sure I need all those
        vals (mapcar 'getvar vars)
  )
  (vla-endundomark *doc*)
  (vla-startundomark *doc*)
  (and
    (vl-load-com)
    (mapcar 'setvar vars '(0 0 0))
    (vl-cmdf "_.expert" (getvar "expert")) ;; dummy command
    (setq e (car (entsel "\nSelect source Cogo point: ")))
    (setq obj (vlax-ename->vla-object e))
    (setq rot (vlax-get obj 'LabelRotation))
    (princ "\nSelect target points to match label rotation...")
    (setq ss (ssget '((0 . "AECC_COGO_POINT"))))
    (repeat (setq i (sslength ss))
      (setq obj (vlax-ename->vla-object (ssname ss (setq i (1- i)))))
      (vlax-put obj 'LabelRotation rot)
      (vla-update obj)
      1
    )
  )
  (*error* nil)
)
(defun c:MLR ()(c:MatchLabelRotation))

John F. Uhden