Author Topic: Weird i know - Text Dynamically ontop of Text  (Read 1757 times)

0 Members and 1 Guest are viewing this topic.

MSTG007

  • Gator
  • Posts: 2601
  • I can't remeber what I already asked! I need help!
Weird i know - Text Dynamically ontop of Text
« on: March 09, 2018, 09:59:45 AM »
I am working on a way to show a tape of "halo text". I have the dtext on 2 different layers. The bottom layer(Black) is a field showing the contents of the top layer (White) text.

So my question is. I can manually get this setup. I did not know if I can find a routine that can copy the text and paste it ontop of the (copied text) with a field of the contents from it.

Last thing I usually do, is create a group out of them. That way I can double click the group and change the text in the properties box and everything dynamically updates upon a regen.

I know this is weird... but it does a pretty good job specially over aerials (Road Names, etc.)


Thanks for some ideas!
Civil3D 2020

mjfarrell

  • Seagull
  • Posts: 14444
  • Every Student their own Lesson
Re: Weird i know - Text Dynamically ontop of Text
« Reply #1 on: March 09, 2018, 10:36:29 AM »
That's an interesting idea.... trick, whatever.

The super coders here will be right along to make it happen for you within the hour.


I don't code but...for those that do....should be a pretty easy task.
I mean basically it's two pieces of text...
Be your Best


Michael Farrell
http://primeservicesglobal.com/

MSTG007

  • Gator
  • Posts: 2601
  • I can't remeber what I already asked! I need help!
Re: Weird i know - Text Dynamically ontop of Text
« Reply #2 on: March 09, 2018, 10:38:24 AM »
You know... I might not be a coder but I do have the craziest ideas sometimes...
Civil3D 2020

PKENEWELL

  • Bull Frog
  • Posts: 317
"When you are asked if you can do a job, tell 'em, 'Certainly I can!' Then get busy and find out how to do it." - Theodore Roosevelt

mjfarrell

  • Seagull
  • Posts: 14444
  • Every Student their own Lesson
Re: Weird i know - Text Dynamically ontop of Text
« Reply #4 on: March 09, 2018, 12:24:56 PM »
That looks interesting...although I see in the comments that the function is dependent on the plugin being installed.
Be your Best


Michael Farrell
http://primeservicesglobal.com/

Lee Mac

  • Seagull
  • Posts: 12913
  • London, England
Re: Weird i know - Text Dynamically ontop of Text
« Reply #5 on: March 09, 2018, 01:08:59 PM »
Here's a quickly written solution using some existing functions -

Code - Auto/Visual Lisp: [Select]
  1. (defun c:halo ( / idx obj sel src sty tab )
  2.     (setq sty "Halo") ;; Textstyle for copied text
  3.     (cond
  4.         (   (not (tblsearch "style" sty))
  5.             (princ (strcat "\nText Style \"" sty "\" does not exist in this drawing."))
  6.         )
  7.         (   (setq sel (ssget '((0 . "TEXT"))))
  8.             (setq tab (LM:sortentstable (vlax-get-property (LM:acdoc) (if (= 1 (getvar 'cvport)) 'paperspace 'modelspace))))
  9.             (repeat (setq idx (sslength sel))
  10.                 (setq idx (1- idx)
  11.                       src (vlax-ename->vla-object (ssname sel idx))
  12.                       obj (vla-copy src)
  13.                 )
  14.                 (vla-put-textstring obj (strcat "%<\\AcObjProp Object(%<\\_ObjId " (LM:objectid src) ">%).TextString>%"))
  15.                 (vla-put-stylename obj sty)
  16.                 (vlax-invoke tab 'movebelow (list obj) src)
  17.             )
  18.         )
  19.     )
  20.     (princ)
  21. )
  22.  
  23. ;; Catch Apply  -  Lee Mac
  24. ;; Applies a function to a list of parameters and catches any exceptions.
  25.  
  26. (defun LM:catchapply ( fnc prm / rtn )
  27.     (if (not (vl-catch-all-error-p (setq rtn (vl-catch-all-apply fnc prm))))
  28.         rtn
  29.     )
  30. )
  31.  
  32. ;; Sortents Table  -  Lee Mac
  33. ;; Retrieves the Sortents Table object.
  34. ;; obj - [vla] Block Container Object
  35.  
  36. (defun LM:sortentstable ( obj / dic )
  37.     (cond
  38.         (   (LM:catchapply 'vla-item (list (setq dic (vla-getextensiondictionary obj)) "acad_sortents")))
  39.         (   (LM:catchapply 'vla-addobject  (list dic "acad_sortents" "AcDbSortentsTable")))
  40.     )
  41. )
  42.  
  43. ;; ObjectID  -  Lee Mac
  44. ;; Returns a string containing the ObjectID of a supplied VLA-Object
  45. ;; Compatible with 32-bit & 64-bit systems
  46.  
  47. (defun LM:objectid ( obj )
  48.     (eval
  49.         (list 'defun 'LM:objectid '( obj )
  50.             (if (vlax-method-applicable-p (vla-get-utility (LM:acdoc)) 'getobjectidstring)
  51.                 (list 'vla-getobjectidstring (vla-get-utility (LM:acdoc)) 'obj ':vlax-false)
  52.                '(itoa (vla-get-objectid obj))
  53.             )
  54.         )
  55.     )
  56.     (LM:objectid obj)
  57. )
  58.  
  59. ;; Active Document  -  Lee Mac
  60. ;; Returns the VLA Active Document Object
  61.  
  62. (defun LM:acdoc nil
  63.     (LM:acdoc)
  64. )
  65.  

Grrr1337

  • Swamp Rat
  • Posts: 812
Re: Weird i know - Text Dynamically ontop of Text
« Reply #6 on: March 09, 2018, 01:20:00 PM »
BTW If I remember correctly textstyles that use fontfile with ".shx" extension, the graphical texts of these same textstyles can be bold-ed through the lineweight property.
(apply ''((a b c)(a b c))
  '(
    (( f L ) (apply 'strcat (f L)))
    (( L ) (if L (cons (chr (car L)) (f (cdr L)))))
    (72 101 108 108 111 32 87 111 114 108 100)
  )
)
vevo.bg

MSTG007

  • Gator
  • Posts: 2601
  • I can't remeber what I already asked! I need help!
Re: Weird i know - Text Dynamically ontop of Text
« Reply #7 on: March 09, 2018, 01:24:59 PM »
I was just going to mention that.... This is the font shx I am using...

fkg.shx

http://www.cadtutor.net/forum/printthread.php?t=39712&pp=10

And the lineweight I am using is 1.40 mm
Civil3D 2020

MSTG007

  • Gator
  • Posts: 2601
  • I can't remeber what I already asked! I need help!
Re: Weird i know - Text Dynamically ontop of Text
« Reply #8 on: March 09, 2018, 01:51:45 PM »
still messin around on this one. . . tear it up lol

Code: [Select]
(defun c:halo ( / idx obj sel src sty tab )

    (setq sty "Halo Text") ;; Textstyle for copied text

    (cond

        (   (not (tblsearch "style" sty))

            (princ (strcat "\nText Style \"" sty "\" does not exist in this drawing."))

       )

        (   (setq sel (ssget '((0 . "TEXT"))))

            (setq tab (LM:sortentstable (vlax-get-property (LM:acdoc) (if (= 1 (getvar 'cvport)) 'paperspace 'modelspace))))

            (repeat (setq idx (sslength sel))

                (setq idx (1- idx)

                      src (vlax-ename->vla-object (ssname sel idx))

                      obj (vla-copy src)

                )

                (vla-put-textstring obj (strcat "%<\\AcObjProp Object(%<\\_ObjId " (LM:objectid src) ">%).TextString>%"))

                (vla-put-stylename obj sty)

                (vlax-invoke tab 'movebelow (list obj) src)

            )

        )

    )

    (princ)

)

 

;; Catch Apply  -  Lee Mac

;; Applies a function to a list of parameters and catches any exceptions.

 

(defun LM:catchapply ( fnc prm / rtn )

    (if (not (vl-catch-all-error-p (setq rtn (vl-catch-all-apply fnc prm))))

        rtn

    )

)

 

;; Sortents Table  -  Lee Mac

;; Retrieves the Sortents Table object.

;; obj - [vla] Block Container Object

 

(defun LM:sortentstable ( obj / dic )

    (cond

        (   (LM:catchapply 'vla-item (list (setq dic (vla-getextensiondictionary obj)) "acad_sortents")))

        (   (LM:catchapply 'vla-addobject  (list dic "acad_sortents" "AcDbSortentsTable")))

    )

)

 

;; ObjectID  -  Lee Mac

;; Returns a string containing the ObjectID of a supplied VLA-Object

;; Compatible with 32-bit & 64-bit systems

 

(defun LM:objectid ( obj )

    (eval

        (list 'defun 'LM:objectid '( obj )

            (if (vlax-method-applicable-p (vla-get-utility (LM:acdoc)) 'getobjectidstring)

                (list 'vla-getobjectidstring (vla-get-utility (LM:acdoc)) 'obj ':vlax-false)

               '(itoa (vla-get-objectid obj))

            )

        )

    )

    (LM:objectid obj)

)

 

;; Active Document  -  Lee Mac

;; Returns the VLA Active Document Object

 

(defun LM:acdoc nil

    (eval (list 'defun 'LM:acdoc 'nil (vla-get-activedocument (vlax-get-acad-object))))

    (LM:acdoc)

)

 

(vl-load-com) (princ)



;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(defun C:HALOTEXT()
(command "._style" "HALO TEXT" "fkg.shx" "0.3" "1.0" "0" "no" "no" )
(command "-layer" "make" "TBWHITE" "color" "Truecolor" "255,255,255" "" "")
(command "-layer" "make" "TBBLACK" "color" "Truecolor" "0,0,0" "" "")
(command "._Text" "_S" "HALO TEXT" "17.125,5.375" 0.1875 "HALO TEXT")
(command "_change" "last" "" "properties" "lw" "1.4" "")
(command "lwdisplay" "on")
(c:HALO)
;;Stuck here... I Have to type in previous lol...
(command "_change" "last" "" "properties" "layer" "TBWHITE" "")
(command "_change" "last" "" "properties" "lw" "bylayer" "")
(command "._draworder" "_l" "" "_b")
(command "_zoom" "Extents")
(setq st (ssget "_X" '((0 . "TEXT,MTEXT") (7 . "HALO TEXT"))))
(command ".-group" "create" "HALO" "" "previous" "")
(princ))
(C:HALOTEXT)

Civil3D 2020

ronjonp

  • Needs a day job
  • Posts: 7527
Re: Weird i know - Text Dynamically ontop of Text
« Reply #9 on: March 09, 2018, 02:43:26 PM »
Try this version to group the two objects:
Code - Auto/Visual Lisp: [Select]
  1. (defun c:halo ( / idx grp grps obj sel src sty tab )
  2.     (setq sty "Halo") ;; Textstyle for copied text
  3.     (cond
  4.         (   (not (tblsearch "style" sty))
  5.             (princ (strcat "\nText Style \"" sty "\" does not exist in this drawing."))
  6.         )
  7.         (   (setq sel (ssget '((0 . "TEXT"))))
  8.             (setq tab (LM:sortentstable (vlax-get-property (LM:acdoc) (if (= 1 (getvar 'cvport)) 'paperspace 'modelspace))))
  9.             ;; RJP added group
  10.             (setq grps (vla-get-groups (LM:acdoc)))
  11.             (repeat (setq idx (sslength sel))
  12.                 (setq idx (1- idx)
  13.                       src (vlax-ename->vla-object (ssname sel idx))
  14.                       obj (vla-copy src)
  15.                 )
  16.                 (vla-put-textstring obj (strcat "%<\\AcObjProp Object(%<\\_ObjId " (LM:objectid src) ">%).TextString>%"))
  17.                 (vla-put-stylename obj sty)
  18.                 (vlax-invoke tab 'movebelow (list obj) src)
  19.                 ;; RJP added group
  20.                 (setq grp (vla-add grps "*"))
  21.                 (vlax-invoke grp 'appenditems (list src obj))
  22.             )
  23.         )
  24.     )
  25.     (princ)
  26. )

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC