Author Topic: Modify a MultiLeader text style, leader style ...  (Read 8990 times)

0 Members and 1 Guest are viewing this topic.

Hangman

  • Swamp Rat
  • Posts: 563
Modify a MultiLeader text style, leader style ...
« on: March 02, 2011, 05:21:46 PM »
I am curious as I am putting a LiSP together to change text from one style to another and move all text and leaders to the text layer.
I started playing with MultiLeaders and have come across this interesting problem.

So here is a Multileader:
Code: [Select]
Select object: ((-1 . <Entity name: -40570370>) (0 . "MULTILEADER") (330 .
<Entity name: -405740f8>) (5 . "EF5A") (100 . "AcDbEntity") (67 . 1) (410 .
"BORDER") (8 . "0") (100 . "AcDbMLeader") (270 . 2) (300 . "CONTEXT_DATA{") (40
. 1.0) (10 16.8211 12.9629 0.0) (41 . 0.125) (140 . 0.18) (145 . 0.09) (174 .
1) (175 . 6) (176 . 0) (177 . 0) (290 . 1) (304 . "this is a test\\Pa real
test") (11 0.0 0.0 1.0) (340 . <Entity name: -405761d8>) (12 16.9111 13.0264
0.0) (13 1.0 0.0 0.0) (42 . 0.0) (43 . 0.0) (44 . 0.0) (45 . 1.0) (170 . 1) (90
. -1073741824) (171 . 1) (172 . 5) (91 . -1073741824) (141 . 0.0) (92 . 0) (291
. 0) (292 . 0) (173 . 0) (293 . 0) (142 . 0.0) (143 . 0.0) (294 . 0) (295 . 0)
(296 . 0) (110 16.2087 12.4361 0.0) (111 1.0 0.0 0.0) (112 0.0 1.0 0.0) (297 .
0) (302 . "LEADER{") (290 . 1) (291 . 1) (10 16.5711 12.9629 0.0) (11 1.0 0.0
0.0) (90 . 0) (40 . 0.25) (304 . "LEADER_LINE{") (10 16.2087 12.4361 0.0) (91 .
0) (170 . 1) (92 . -1056964608) (340 . <Entity name: 0>) (171 . -2) (40 . 0.0)
(341 . <Entity name: 0>) (93 . 0) (305 . "}") (271 . 0) (303 . "}") (272 . 9)
(273 . 9) (301 . "}") (340 . <Entity name: -40576148>) (90 . 17056768) (170 .
1) (91 . -1056964608) (341 . <Entity name: -405761a8>) (171 . -2) (290 . 1)
(291 . 1) (41 . 0.25) (42 . 0.18) (172 . 2) (343 . <Entity name: -405761d8>)
(173 . 1) (95 . 6) (174 . 1) (175 . 0) (92 . -1056964608) (292 . 0) (93 .
-1056964608) (10 1.0 1.0 1.0) (43 . 0.0) (176 . 0) (293 . 0) (294 . 0) (178 .
0) (179 . 1) (45 . 1.0) (271 . 0) (272 . 9) (273 . 9))

And I want to change the Leader style and Text style to another type, so I need to pull the info from DXF 340 & 343 - right?

Code: [Select]
Command: (SETQ A (CDR (ASSOC 343 Y)))
<Entity name: -405761d8>

Command: (SETQ B (ENTGET A))
((-1 . <Entity name: -405761d8>) (0 . "STYLE") (330 . <Entity name: -405763e8>)
(5 . "5D") (100 . "AcDbSymbolTableRecord") (100 . "AcDbTextStyleTableRecord")
(2 . "Standard") (70 . 0) (40 . 0.125) (41 . 1.0) (50 . 0.0) (71 . 0) (42 .
0.125) (3 . "ARIAL.TTF") (4 . ""))

Now standard Text and MText uses DXF 7 to change its style, but Multileaders have DXF 2.

I've tried this (already knowing it won't work):
Code: [Select]
(ENTMOD (SUBST (CONS 343 TSTYL)(ASSOC 343 (ENTGET B))(ENTGET B)))
Quote
; error: bad DXF group: (343 . "NWP")

So, my question(s) is this;  How do you change a MultiLeader from one text style to another?  Perhaps I need to ask this question a different way; How do you extract the DXF code so you can change it?  Is there a different way the DXF needs to be changed than that above after it is extracted?
I don't think my questions are correct for what I am trying to find, but I am at a loss of knowledge to ask the proper questions to this particular subject.

I thought for sure I had read this in another post here somewhere, but I have failed to find it.

Thanks for your thoughts and suggestions.
Hangman  8)

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Drafting Board, Mechanical Arm, KOH-I-NOOR 0.7mm
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Lee Mac

  • Seagull
  • Posts: 12671
  • London, England
Re: Modify a MultiLeader text style, leader style ...
« Reply #1 on: March 02, 2011, 05:26:12 PM »
I would be inclined to go the VL route on this one, look into vla-put-TextStyleName.

Obviously this doesn't dampen your curiousity however, so I'm sure one of the DXF-oriented guys will stop by soon  :-)

Jeff_M

  • King Gator
  • Posts: 4040
  • C3D user & customizer
Re: Modify a MultiLeader text style, leader style ...
« Reply #2 on: March 02, 2011, 06:38:15 PM »
Based on this:  error: bad DXF group: (343 . "NWP") and this from the entity list: (343 . <Entity name: -405761d8>) I could see that you were passing the text style name, where the 343 group is expecting an ENAME. So I tested and it shows as having been revised, but the actual text in the drawing does not change. Even with an (entupd) it stays as it started. I can (entget/entsel) again and it shows the new style as being in use, but it still displays as it did originally, and the Properties Palette shows it as using the original style. Based on this, I will agree with Lee and say to use ActiveX (of course, that's the first thing I thought of anyway, because all this DXF stuff is mind-numbing).

Command: (setq ent (car (entsel)))

Select object: <Entity name: -17efb8>

Command: (setq newstyle (tblobjname "STYLE" "L80"))
<Entity name: -1b0250>

Command: (entmod (subst (cons 343 newstyle) (assoc 343 (entget ent)) (entget
ent)))
((-1 . <Entity name: -17efb8>) (0 . "MULTILEADER") (330 . <Entity name:
-1b03f0>) (5 . "17B09") (100 . "AcDbEntity") (67 . 0) (410 . "Model") (8 .
"TEXTURA 2") (100 . "AcDbMLeader") (270 . 2) (300 . "CONTEXT_DATA{") (40 . 1.0)
(10 16760.8 -1342.31 0.0) (41 . 0.18) (140 . 0.18) (145 . 0.09) (174 . 1) (175
. 6) (176 . 0) (177 . 0) (290 . 1) (304 . "hdbsjhbshjb\\Pjnsdjn") (11 0.0 0.0
1.0) (340 . <Entity name: -1b0368>) (12 16760.9 -1342.19 0.0) (13 1.0 0.0 0.0)
(42 . 0.0) (43 . 0.0) (44 . 0.0) (45 . 1.0) (170 . 1) (90 . -1073741824) (171 .
1) (172 . 5) (91 . -1073741824) (141 . 1.25) (92 . 0) (291 . 1) (292 . 1) (173
. 0) (293 . 0) (142 . 0.0) (143 . 0.0) (294 . 0) (295 . 0) (296 . 0) (110
16720.9 -1271.01 0.0) (111 1.0 0.0 0.0) (112 0.0 1.0 0.0) (297 . 0) (302 .
"LEADER{") (290 . 1) (291 . 1) (10 16760.4 -1342.31 0.0) (11 1.0 0.0 0.0) (90 .
0) (40 . 0.36) (304 . "LEADER_LINE{") (10 16720.9 -1271.01 0.0) (91 . 0) (170 .
1) (92 . -1056964608) (340 . <Entity name: 0>) (171 . -2) (40 . 0.0) (341 .
<Entity name: 0>) (93 . 0) (305 . "}") (271 . 0) (303 . "}") (272 . 9) (273 .
9) (301 . "}") (340 . <Entity name: -19ef30>) (90 . 279552) (170 . 1) (91 .
-1056964608) (341 . <Entity name: -1b0350>) (171 . -2) (290 . 1) (291 . 1) (41
. 0.36) (42 . 0.18) (172 . 2) (343 . <Entity name: -1b0250>) (173 . 1) (95 . 6)
(174 . 1) (175 . 0) (92 . -1056964608) (292 . 0) (93 . -1056964608) (10 1.0 1.0
1.0) (43 . 0.0) (176 . 0) (293 . 0) (294 . 0) (178 . 0) (179 . 1) (45 . 1.0)
(271 . 0) (272 . 9) (273 . 9))

Command: (entupd ent)
<Entity name: -17efb8>

Chris

  • Swamp Rat
  • Posts: 547
Re: Modify a MultiLeader text style, leader style ...
« Reply #3 on: March 03, 2011, 09:16:59 AM »
I have found based on my experience, that multileaders are more successfully modified going the VL route for the majority of the properties (if not all), as opposed to the dxf route.
Christopher T. Cowgill, P.E.
AEC Collection 2020 (C3D)
Win 10

Xander

  • Guest
Re: Modify a MultiLeader text style, leader style ...
« Reply #4 on: November 30, 2011, 01:10:30 AM »
Firstly, I'm sorry to revive this thread  :oops:
I've recently decided to create MLeader style through DXF codes opposed to VisualLisp, and stumbled upon a rather curious issue...

The DXF code references for 91,93,94 (etc) indicate they are for the entity colors, however the are a 10 digit color code?!?! :realmad:

After a little trial and error, I've pieced together a simple function to convert indexed and true colors into this 10 digit form.  Making my life just that little bit easier to create MLeader styles.


Code: [Select]
;;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-;;
;|
<function>transposecolor</function>
<sumary>Transposes an input color (indexed or true color) into a 10 digit color representation for MLeader DXF codes.
0 = ByBlock
1-255 = Indexed Colors
256 = ByLayer
xxx,xxx,xxx = True Color
</sumary>
<returns>10 digit color representation otherwise ByLayer.</returns>
<examples>
(CONS 91 (transposecolor "255,255,200"))
(CONS 91 (transposecolor "0"))
(CONS 91 (transposecolor "255"))
</examples>
TEST DATA
ByLayer:     -1073741824
ByBlock:     -1056964608
1 Red:       -1023410175
2 Yellow:    -1023410174
3 Green:     -1023410173
4 Cyan:      -1023410172
250:         -1023409926
255,255,255  -1023410177
0,0,0        -1040187392
1,0,0        -1073741824
255,0,0      -1023475712
0,1,0        -1040187136
0,255,0      -1040122112
0,0,1        -1040187391
0,0,255      -1040187137
100,100,100  -1033608092
|;
;;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-;;
(DEFUN transposecolor ($color / $list $value)
    (DEFUN split_string ($target
                         $delimeter
                         /
                         $target_length ;Target Find Length
                         $counter ;Counter
                         $first_char ;First Character
                         $current_char ;Current Character
                         $first ;First String
                         $return ;Return List
                         $current ;Current Remainaing String
                        )
        (SETQ $target_length (STRLEN $target)
              $counter       1
              $first_char    0
              $first         0
        )
        (REPEAT $target_length
            (SETQ $current_char (SUBSTR $target $counter 1))
            (IF (NOT (= $current_char $delimeter))
                (PROGN
                    (IF (= $first_char 0)
                        (PROGN
                            (SETQ $current $current_char)
                            (SETQ $first_char 1)
                        )
                        (SETQ $current (STRCAT $current $current_char))
                    )
                )
                (PROGN
                    (IF (= $first_char 0)
                        (SETQ $first_char 0)
                        (PROGN
                            (IF (= $first 0)
                                (PROGN
                                    (SETQ $return (LIST $current))
                                    (SETQ $first 1)
                                    (SETQ $first_char 0)
                                )
                                (PROGN
                                    (SETQ $return (APPEND $return (LIST $current)))
                                    (SETQ $first_char 0)
                                )
                            )
                        )
                    )
                )
            )
            (IF (= $counter $target_length)
                (IF (NOT (= $current_char $delimeter))
                    (SETQ $return (APPEND $return (LIST $current)))
                )
            )
            (SETQ $counter (+ $counter 1))
        )
        (SETQ $return $return)
    )

    ;;Set the default return value as 'ByLayer'
    (SETQ $value -1073741824)
    (SETQ $list (split_string $color ","))
    (COND
        ;;Indexed Color
        ((= (LENGTH $list) 1)
         (IF (>= 3 (STRLEN (CAR $list)))
             (IF (AND (< 0 (ATOI (CAR $list))) (> 256 (ATOI (CAR $list))))
                 (SETQ $value (+ -1023410176 (ATOI (CAR $list))))
                 (COND
                     ;;ByBlock
                     ((= (ATOI (CAR $list)) 0)
                      (SETQ $value -1056964608)
                     )
                     ;;ByLayer
                     ((= (ATOI (CAR $list)) 256)
                      (SETQ $value -1073741824)
                     )
                 )
             )
         )
        )
        ;;True Color
        ((= (LENGTH $list) 3)
         (SETQ $value
                  (+ -1040187392
                     (* (ATOI (NTH 0 $list)) 256 256)
                     (* (ATOI (NTH 1 $list)) 256)
                     (ATOI (NTH 2 $list))
                  )
         )
        )
    )
    $value
)


Lee Mac

  • Seagull
  • Posts: 12671
  • London, England
Re: Modify a MultiLeader text style, leader style ...
« Reply #5 on: November 30, 2011, 08:07:39 AM »
The DXF code references for 91,93,94 (etc) indicate they are for the entity colors, however the are a 10 digit color code?!?! :realmad:

I feel your pain...

The MLeaderStyle Colours are a mixture of a 24-bit TrueColor representation with a few extra bits included to represent ACI colours with the same code, all of which is shifted resulting in a negative 10-digit value.

Here are my functions to convert both ways:

Code: [Select]
;; Colour -> MLeaderStyleColour  -  Lee Mac
;; Args: c - ACI Colour or List of (r g b)

(defun Colour->MLeaderStyleColour ( c )
    (cond
        (   (listp c)
            (+ -1040187392 (apply 'LM:RGB->True c))
        )
        (   (= 0 c)
            -1056964608
        )
        (   (= 256 c)
            -1073741824
        )
        (   (< 0 c 256)
            (+ -1023410176 (LM:RGB->True 0 0 c))
        )
    )
)

;; MLeaderStyleColour -> Colour  -  Lee Mac
;; Args: c - MLeaderStyle Colour value.
;; Returns: ACI Colour or List of (r g b)

(defun MLeaderStyleColour->Colour ( c )
    (if (< 0 (logand 16777216 c))
        (last (LM:True->RGB c))
        (if (equal '(0 0 0) (setq c (LM:True->RGB c))) 256 c)
    )
)

;; True -> RGB  -  Lee Mac
;; Args: c - True Colour

(defun LM:True->RGB ( c )
    (list
        (lsh (lsh (fix c)  8) -24)
        (lsh (lsh (fix c) 16) -24)
        (lsh (lsh (fix c) 24) -24)
    )
)

;; RGB -> True  -  Lee Mac
;; Args: r,g,b - Red,Green,Blue values

(defun LM:RGB->True ( r g b )
    (+
        (lsh (fix r) 16)
        (lsh (fix g)  8)
        (fix b)
    )
)

e.g.:

Code: [Select]
_$ (Colour->MleaderstyleColour 0)
-1056964608
_$ (Colour->MleaderstyleColour 256)
-1073741824
_$ (Colour->MleaderstyleColour 254)
-1023409922
_$ (Colour->MleaderstyleColour '(200 100 50))
-1027054542
_$
_$
_$ (MleaderstyleColour->Colour -1056964608)
0
_$ (MleaderstyleColour->Colour -1073741824)
256
_$ (MleaderstyleColour->Colour -1023409922)
254
_$ (MleaderstyleColour->Colour -1027054542)
(200 100 50)

More colour conversion here.
« Last Edit: November 30, 2011, 08:13:53 AM by Lee Mac »

alanjt

  • Needs a day job
  • Posts: 5349
  • Standby for witty remark...
Re: Modify a MultiLeader text style, leader style ...
« Reply #6 on: November 30, 2011, 08:20:14 AM »
I have found based on my experience, that multileaders are more successfully modified going the VL route for the majority of the properties (if not all), as opposed to the dxf route.
Agreed. It's almost pointless trying to modify an MLeader without VL.

Here's a thread I started when trying to battle some ssget filtering for MLeaders.
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox

Xander

  • Guest
Re: Modify a MultiLeader text style, leader style ...
« Reply #7 on: November 30, 2011, 06:13:28 PM »
Thanks! I never knew of the 'lsh' or 'listp' methods!  :-o

Quote
Returns the logical bitwise shift of an integer by a specified number of bits

That would have simplified my life yesterday.

Fortunately I have no need for selecting MLeader entity's, not yet at-least, I just need to create the style.

Thanks once again.
« Last Edit: November 30, 2011, 06:32:55 PM by Xander »

Lee Mac

  • Seagull
  • Posts: 12671
  • London, England
Re: Modify a MultiLeader text style, leader style ...
« Reply #8 on: December 01, 2011, 07:27:24 AM »
You're welcome Xander  :-)