Author Topic: Dynamic Align Text to Curve { with Reactors }  (Read 28753 times)

0 Members and 1 Guest are viewing this topic.

Lee Mac

  • Seagull
  • Posts: 12267
  • London, England
Re: Dynamic Align Text to Curve { with Reactors }
« Reply #30 on: November 17, 2009, 06:35:05 PM »
Correction - it happens all the time.

Will get it sorted  :-)

Lee Mac

  • Seagull
  • Posts: 12267
  • London, England
Re: Dynamic Align Text to Curve { with Reactors }
« Reply #31 on: November 17, 2009, 06:49:58 PM »
Ok, it seemed to be just a simple rounding error - let me know how you get on with it now.  :-)

Code in first post updated.

Lee Mac

  • Seagull
  • Posts: 12267
  • London, England
Re: Dynamic Align Text to Curve { with Reactors }
« Reply #32 on: November 17, 2009, 07:11:22 PM »
Sorry for all the updates...

Just had an idea to allow the user to manually input the offset distance - and also a few other bug fixes to do with the rounding of doubles..  :-)

Code in first post updated to Version 2.0

Bug-less me hopes  :wink:

cmwade77

  • Swamp Rat
  • Posts: 1206
Re: Dynamic Align Text to Curve { with Reactors }
« Reply #33 on: November 17, 2009, 07:13:37 PM »
Much better, thank you.

Here is the latest on my IT as well, with a few bug fixes along the way in my code and combining with your code through version 1.9.

Lee Mac

  • Seagull
  • Posts: 12267
  • London, England
Re: Dynamic Align Text to Curve { with Reactors }
« Reply #34 on: November 17, 2009, 07:17:02 PM »
Nice one Chris,

Just a small thing, but when setting Text Layers/Styles etc, you could got the VL route and use (vla-put-StyleName tObj... or (vla-put-Height tObj... which saves you using command calls, and entlast.  :-)

 

cmwade77

  • Swamp Rat
  • Posts: 1206
Re: Dynamic Align Text to Curve { with Reactors }
« Reply #35 on: November 17, 2009, 07:27:31 PM »
Yeah, I am going to clean it up, but I have to learn it all first (your code will be a great help with this)

Also, the one attached to this email incorporates your 2.0 routine.
« Last Edit: November 17, 2009, 07:35:19 PM by cmwade77 »

Lee Mac

  • Seagull
  • Posts: 12267
  • London, England
Re: Dynamic Align Text to Curve { with Reactors }
« Reply #36 on: November 17, 2009, 07:33:28 PM »
No problem Chris, happy I could help with your learning  :-)

cmwade77

  • Swamp Rat
  • Posts: 1206
Re: Dynamic Align Text to Curve { with Reactors }
« Reply #37 on: November 17, 2009, 07:36:30 PM »
Oops spoke too soon, it looks like your code doesn't show creating layers or text styles, hmm, well, I will have to look into it, honestly I don't know much bout the VL route, just enough to be dangerous.  :lol:

Seriously, if you have any suggestions on where I can figure some of this out, I would appreciate it.

Lee Mac

  • Seagull
  • Posts: 12267
  • London, England
Re: Dynamic Align Text to Curve { with Reactors }
« Reply #38 on: November 17, 2009, 07:40:39 PM »
Yeah, you will still have to accomodate for missing styles/layers etc  ;-)

To add a Layer in VL for example:

Code: [Select]
(vla-add
  (vla-get-layers
    (vla-get-ActiveDocument
      (vlax-get-acad-object)))  "New Layer")

But, it is much better practice to store the ActiveDocument in a variable, so that vlax-get-acad-object is not called multiple times.

The VLIDE help files on Visual LISP are mostly based around VBA, but you can read between the lines to get to know what is going on with Visual LISP.

I would still say that the best method is learning from example, and where better to find a multitude of examples than on a forum... :-)

Otherwise, AfraLISP has a section on Visual LISP that may help  :-)

Lee

cmwade77

  • Swamp Rat
  • Posts: 1206
Re: Dynamic Align Text to Curve { with Reactors }
« Reply #39 on: November 18, 2009, 12:23:25 PM »
Ok, thank you, I have setting colors and linetypes down, now how do I set the Plot Style? Also, I do I set the lineweight to "Default"?

Never mind, I figured it out, thank you, I am working to cleanup the code now and will post the updated version shortly, as I would love to get some more input on the code.
« Last Edit: November 18, 2009, 12:39:20 PM by cmwade77 »

cmwade77

  • Swamp Rat
  • Posts: 1206
Re: Dynamic Align Text to Curve { with Reactors }
« Reply #40 on: November 18, 2009, 12:55:26 PM »
Ok, now how do I define a text style as annotative? I can't seem to find that anywhere.

But I can find a previous post that I had made about using entmake to create annotative text, but in this case I want to set the style as annotative.


This is what I have so far:
Code: [Select]
(setq ITstyle (vla-add (vla-get-textstyles doc) *IT$tStyle*))
(vla-put-fontfile ITstyle *IT$tFont*)

(vla-put-width ITStyle *IT$tWf*)
(vla-put-obliqueangle ITstyle "0")

(if (= *IT$Anno* T)
(progn
(vla-put-height ITstyle *IT$tSze*)
(vla-put-annotative ITStyle T); <---This line is what doesn't work
)
(vla-put-height ITstyle "0")
)
« Last Edit: November 18, 2009, 02:54:28 PM by cmwade77 »

cmwade77

  • Swamp Rat
  • Posts: 1206
Re: Dynamic Align Text to Curve { with Reactors }
« Reply #41 on: November 18, 2009, 03:37:26 PM »
Ok, here is my cleaned up code, I was able to remove the error handling modifications that I made (which didn't always work all that well anyway) due to the changes, but I can't get the style working properly us the VL methods with annotative scaling, I left the code that I was trying, but remarked it out.

Lee Mac

  • Seagull
  • Posts: 12267
  • London, England
Re: Dynamic Align Text to Curve { with Reactors }
« Reply #42 on: November 18, 2009, 05:03:58 PM »
Nice one Chris,

To be honest, I have never used annotative text, but that said - I cannot immediately see a way in VL to define a Text Style as Annotative - I would be interested if anyone else could offer a method to accomplish such a task.  :-)

T.Willey

  • Needs a day job
  • Posts: 5218
Re: Dynamic Align Text to Curve { with Reactors }
« Reply #43 on: November 18, 2009, 05:46:04 PM »
To add annotative options to text, a simple way is:
Code: [Select]
(entmod
    (append
        (entget (tblobjname "style" <TextStyleNameHere>))
        (list '(-3 ("AcadAnnotative" (1000 . "AnnotativeData") (1002 . "{") (1070 . 1) (1070 . 1) (1002 . "}"))))
    )
)

A little more experimenting might show how to use ActiveX, but I don't add Xdata too often, so maybe this will get the juices flowing.

Edit:  Should add I don't work in an Acad that uses annotative, so that was a real quick look into it.
« Last Edit: November 18, 2009, 06:00:34 PM by T.Willey »
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

Lee Mac

  • Seagull
  • Posts: 12267
  • London, England
Re: Dynamic Align Text to Curve { with Reactors }
« Reply #44 on: November 18, 2009, 06:11:05 PM »
Give this a shot:

Code: [Select]
(defun putAnno (styl / xtype xval)
  ;; by Lee McDonnell
 
  (setq xtype
    (vlax-make-variant
      (vlax-safearray-fill
        (vlax-make-safearray
          vlax-vbInteger '(0 . 7))
        '(1001 1000 1070 1000 1002 1070 1070 1002))))

  (setq xval
    (vlax-make-variant
      (vlax-safearray-fill
        (vlax-make-safearray
          vlax-vbVariant '(0 . 7))
        (list "AcadAnnotative" "AnnotativeData" 1 "AnnotativeData" "{" 1 1 "}"))))

  (vla-setXData
    (vla-item
      (vla-get-TextStyles
        (vla-get-ActiveDocument
          (vlax-get-acad-object))) styl) xtype xval))


Requires valid TextStyle String argument