Shift MText by changing base point with individual Object Data Value

Shift MText by changing base point with individual Object Data Value

S.Röder
Participant Participant
677 Views
1 Reply
Message 1 of 2

Shift MText by changing base point with individual Object Data Value

S.Röder
Participant
Participant

Hello,

 

I have loaded a GML file (NAS format or German ALKIS data) into AutoCAD Map via MAPIMPORT with attached Object Data for the GIS attributes. All imported text objects (Mtext) are placed with the base point "bottom left" on the designated coordinate.

 

In the attached OD attributes there are two values ​​for the base point for each text, each for horizontal alignment ("horizontaleAusrichtung") and vertical alignment ("vertikaleAusrichtung"), which partly deviate from the automatically assigned base point.

 

I would now like to use LISP to check for all texts in the drawing whether the respective text has these OD attributes and possibly provides a different base point placement for correct visualization. If so, this should be assigned accordingly.

 

Due to the German NAS format, there are three German words each for vertical ("Basis", "Mitte", "oben") and horizontal alignment ("linksbündig", "rechtsbündig", "zentrisch"). In combination they represent the nine different possibilities of base point placement.

 

It is important that the base point is reassigned, but that the original coordinate from the import must be retained, so the text itself should be shifted as a result.

 

Attached is a screenshot to clarify what I want to do. Also a test file in 2013 DWG file format.

 

Can someone help me? Suggested solutions are welcome.

 

Thank you for your support!

0 Likes
Accepted solutions (1)
678 Views
1 Reply
Reply (1)
Message 2 of 2

ВeekeeCZ
Consultant
Consultant
Accepted solution

This code should do it.

You just need to fill the rest of the table by group code 71 HERE 

 

(defun c:MTextJustByOD ( / l s i e h v j)

  (setq l '(
(("ZENTRISCH" "MITTE") . 5) (("ZENTRISCH" "RECHTSBÜNDIG") . 6))
) (if (setq s (ssget "_:L" '((0 . "MTEXT")))) (repeat (setq i (sslength s)) (setq e (ssname s (setq i (1- i)))) (and (setq h (ade_odgetfield e "AP_PTO" "horizontaleAusrichtung" 0)) (setq v (ade_odgetfield e "AP_PTO" "vertikaleAusrichtung" 0)) (setq j (cdr (assoc (list (strcase h) (strcase v)) l))) (setpropertyvalue e "Attachment" j)))) (princ) )