Author Topic: How to set textstyle to vertical using Vlisp  (Read 9607 times)

0 Members and 1 Guest are viewing this topic.

Sdoman

  • Guest
How to set textstyle to vertical using Vlisp
« on: April 24, 2006, 02:31:31 PM »
Hi -

I am trying to make a textstyle with vertical text using VLISP.  I can not find any documentation on how to set the vertical property without resorting to using Entmod or Command.  Can anyone help?

Code: [Select]

;; Add a new textstyle to the active document
;; and set its properties
(setq styleobj
       (vla-add (vla-get-textstyles
                  (vla-get-activedocument (vlax-get-acad-object))
                )
                "Test-Vert"
       )
)
(vlax-put-property styleobj 'fontfile "romans.shx")
(vlax-put-property styleobj 'width 0.9)

;; Next line was a guess and doesn't work
;; (vlax-put-property styleobj 'vertical :vlax-true )


;; Here's the result of a dump on the newly created textstyle object:
(vlax-dump-object styleobj t)

; IAcadTextStyle: A named, saved collection of settings that determines the appearance of text characters
; Property values:
;   Application (RO) = #<VLA-OBJECT IAcadApplication 00d077b4>
;   BigFontFile = ""
;   Document (RO) = #<VLA-OBJECT IAcadDocument 014fb3e0>
;   fontFile = ""
;   Handle (RO) = "3CC"
;   HasExtensionDictionary (RO) = 0
;   Height = 0.0
;   LastHeight = 1.0
;   Name (RO) = "Test-Vert"
;   ObjectID (RO) = 2126646368
;   ObjectName (RO) = "AcDbTextStyleTableRecord"
;   ObliqueAngle = 0.0
;   OwnerID (RO) = 2130263064
;   TextGenerationFlag = 0
;   Width = 0.9
; Methods supported:
;   Delete ()
;   GetExtensionDictionary ()
;   GetFont (5)
;   GetXData (3)
;   SetFont (5)
;   SetXData (2)


{fixed dump report, was wrong one}

 
« Last Edit: April 24, 2006, 03:04:32 PM by Steve Doman »

JohnK

  • Administrator
  • Seagull
  • Posts: 10652
Re: How to set textstyle to vertical using Vlisp
« Reply #1 on: April 24, 2006, 03:23:46 PM »
Rotation? ...Couldnt you just rotate it? (Or am i way of base?)
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

Sdoman

  • Guest
Re: How to set textstyle to vertical using Vlisp
« Reply #2 on: April 24, 2006, 03:30:43 PM »
Rotation? ...Couldnt you just rotate it? (Or am i way of base?)

Hi Se7en, thanks for the reply.

I am trying to defin a Textstyle that displays fonts vertically like this:

Code: [Select]

A
B
C
D


I can't use Command because this will be used from a reactor routine.  I wrote a Vlisp subfunction to create textstyles a couple years ago.  Today I wanted to use it to make a vertical textstyle and relized it won't worky.  Maybe it isn't possible using vlisp...

 

Jeff_M

  • King Gator
  • Posts: 4096
  • C3D user & customizer
Re: How to set textstyle to vertical using Vlisp
« Reply #3 on: April 24, 2006, 03:41:55 PM »
Some quick testing with for a style that uses the Simplex.shx font and the Style is retrieved like so:
(setq st1 (vla-item (vla-get-textstyles *doc*) "L80"))

Vertical NOT checked in the Style dialog:
(vla-getfont st1 'Typeface 'Bold 'Italic 'CharSet 'PitchAndFamily)
CharSet returns 1

Vertical IS checked in the Style dialog:
(vla-getfont st1 'Typeface 'Bold 'Italic 'CharSet 'PitchAndFamily)
CharSet returns 0

You can change/set this with SetFont

CADmium

  • Newt
  • Posts: 33
Re: How to set textstyle to vertical using Vlisp
« Reply #4 on: April 24, 2006, 03:59:47 PM »
Code: [Select]
(defun TEXTSTIL-PUT-VERTICAL (TEXTSTILNAME VERTICALFLAG /  TEXTSTIL)
  (if(and(= (type TEXTSTILNAME) 'STR)         
         (setq TEXTSTIL(tblobjname "STYLE" TEXTSTILNAME))
         (setq TEXTSTIL(entget TEXTSTIL))
         (setq FLAG (cdr(assoc 70 TEXTSTIL)))
         (cond
           ((= VERTICALFLAG 1)
             (entmod (subst(cons 70 (logior 4 FLAG))(assoc 70 TEXTSTIL)TEXTSTIL))
           )
           ((= VERTICALFLAG  0)             
             (entmod (subst(cons 70 (- FLAG (logand FLAG 4)))(assoc 70 TEXTSTIL)TEXTSTIL))
           )
         ) 
     )
    VERTICALFLAG
  )
)

to set vertical, if possible
(TEXTSTIL-PUT-VERTICAL "STANDARD" 1)
to unset
(TEXTSTIL-PUT-VERTICAL "STANDARD" 0)
"Bei 99% aller Probleme ist die umfassende Beschreibung des Problems bereits mehr als die Hälfte der Lösung desselben."

Sdoman

  • Guest
Re: How to set textstyle to vertical using Vlisp
« Reply #5 on: April 24, 2006, 04:37:18 PM »
Jeff,

Thanks for the help.  I was able to duplicate your results using GetFont.  But was unable to set vertical using SetFont.  Here's what i came up with using your suggestion.  Is this what you had in mind?

Code: [Select]
(vla-getfont styleobj 'Typeface 'Bold 'Italic 'CharSet 'PitchAndFamily)
(vla-setfont styleobj Typeface Bold Italic 0 PitchAndFamily)

Tried zero and one but no worky.  Still trying...


CADmium-

Thanks for the function.  It works good!  I was trying however to work with vla-objects since I have committed to this style of programming for my application.  However, I may have to use plain AutoLisp in this case.  So thanks again!


LE

  • Guest
Re: How to set textstyle to vertical using Vlisp
« Reply #6 on: April 24, 2006, 04:42:48 PM »
Hi Steve;

I never had use the vertical textstyle... is that flag data inside of an xdata?... I have done some reactors for dimensions and being able to change the xdata to suit my needs... maybe that can be the ticket...

HTH.

Jeff_M

  • King Gator
  • Posts: 4096
  • C3D user & customizer
Re: How to set textstyle to vertical using Vlisp
« Reply #7 on: April 24, 2006, 04:52:26 PM »
Sorry, Steve. I did say 'quick' testing, right? :-)

Now that I've gone back and done some more tests, I'm not sure what the CharSet is getting/controlling....in a new drawing I created a new typical style and listed the CharSet, it was 0  when I was expecting 1. So it appears that, so far, this property is not accessible from ActiveX.

Sdoman

  • Guest
Re: How to set textstyle to vertical using Vlisp
« Reply #8 on: April 24, 2006, 05:42:06 PM »
Hi Steve;

I never had use the vertical textstyle... is that flag data inside of an xdata?... I have done some reactors for dimensions and being able to change the xdata to suit my needs... maybe that can be the ticket...

HTH.

Hi LE,

I never needed a vertical textstyle until recently.  I am Xdata illiterate and therefore never needed to program Xdata.  I did try this:

(vla-GetXData styleobj "" 'xType 'xData)

xType and xData both returned:  nil

Being a newbie at Xdata, I'm probably not doing it correctly.  If I have to go the Xdata route, then I'll just use CADmium's function.   (Although it would be a good experience to try some xdata programming when I have more time.)


Jeff,

Thanks again.  I realized your first reply was a quick check.  No problemo!   It was an interesting try anyhow.  Seems there ought to be a way using vla-objects, but Alas it eludes me/us.
 

LE

  • Guest
Re: How to set textstyle to vertical using Vlisp
« Reply #9 on: April 24, 2006, 05:49:02 PM »
I am not sure [same boat] if that data is in an xdata place, here is something that might be useful:

This is for dimensions:
Code: [Select]
(defun vlax-make-array-type  (lst atype)
  (vlax-safearray-fill
    (vlax-make-safearray
      atype
      (cons 0 (1- (length lst))))
    lst))

(defun fractional-dim  (obj str)
  (vla-setxdata
    obj
    ;; XDataType as Variant (array of short)
    (vlax-make-array-type
      (list 1001 1000 1002 1070 1000 1070 1070 1002)
      vlax-vbinteger)
    ;; XData as Array of Variant
    (vlax-make-array-type
      (list
(vlax-make-variant "ACAD" vlax-vbstring)
(vlax-make-variant "DSTYLE" vlax-vbstring)
(vlax-make-variant "{" vlax-vbstring)
(vlax-make-variant 3 vlax-vbinteger)
(vlax-make-variant str vlax-vbstring)
(vlax-make-variant 277 vlax-vbinteger)
(vlax-make-variant 5 vlax-vbinteger)
(vlax-make-variant "}" vlax-vbstring))
      vlax-vbvariant)))

Not mine...
Code: [Select]
(defun psvp->xdatalist (obj / v1 v2 a b lst)
  (vla-GetXData obj "acad" 'v1 'v2)
  (if
    (= (type v1) 'safearray)
    (setq v1 (vlax-safearray->list v1)))
  (if
    (= (type v2) 'safearray)
    (setq v2 (vlax-safearray->list v2)))
  (mapcar
   '(lambda (a b)
      (if
        (= (type a) 'variant)
        (setq a (vlax-variant-value a)))
      (if
        (= (type b) 'variant)
        (setq b (vlax-variant-value b)))
      (if
        (= (type a) 'safearray)
        (setq a (vlax-safearray->list a)))
      (if
        (= (type b) 'safearray)
        (setq b (vlax-safearray->list b)))
      (setq lst (append lst (list (list a b)))))
    v1 v2)
  lst)

Jeff_M

  • King Gator
  • Posts: 4096
  • C3D user & customizer
Re: How to set textstyle to vertical using Vlisp
« Reply #10 on: April 24, 2006, 05:58:16 PM »
BTW, this 'option' is not stored in XDATA or extension dictionaries, either. Looks like cadmium's is the only way to go right now......

Sdoman

  • Guest
Re: How to set textstyle to vertical using Vlisp
« Reply #11 on: April 24, 2006, 06:56:40 PM »
I am not sure [same boat] if that data is in an xdata place, here is something that might be useful:

This is for dimensions:


Thanks for the example code LE.  Maniupulating Xdata doesn't appear to be the way to go about creating a vertical textstyle, but I'll keep your sample code handy for future reference on other projects. 

BTW, this 'option' is not stored in XDATA or extension dictionaries, either. Looks like cadmium's is the only way to go right now......

That's the way it appears to me too.  Thanks for help Jeff.  And thanks CADmium.
 

LE

  • Guest
Re: How to set textstyle to vertical using Vlisp
« Reply #12 on: April 24, 2006, 07:31:44 PM »
Steve;

See if the attached arx file, might help you.... it works with a2004-2006, please if you use it, run some tests on drawings from scratch.

Quote
Usage: (verticaltextstyle [ textyle as string ])
ie:
(verticaltextstyle "standard")
Return: T or Nil

If the function works for you, it can be adapted to have another argument for the boolean values true or false [vertical property]

Luis.
HTH

Jeff_M

  • King Gator
  • Posts: 4096
  • C3D user & customizer
Re: How to set textstyle to vertical using Vlisp
« Reply #13 on: April 24, 2006, 07:47:58 PM »
Dog gone it Luis! You keep offering up these quick little ARX's as solutions to our ActiveX woes and you are going to FORCE me to wander into the Abyss. :evil:

And I actually think I may do so anyway......Glenn R over at a now defunct website was working on a Curve class that allowed VB(A) users the same VLAX-CURVE functions that VLisp users use without the need for going through the Lisp interpreter. I tested the first few versions for him and I thought he was going to release them for general use, but I have not yet seen them. Maybe Kerry B., if he sees this, can update on this since he, too, was doing some testing on them and I beleive he also knows Glenn personally. Anyway, I was thinking of doing this as there are many times I will use lisp in place of VBA solely for the purpose of being able to easily access the Vlax-curve-* functions.



Jeff_M

  • King Gator
  • Posts: 4096
  • C3D user & customizer
Re: How to set textstyle to vertical using Vlisp
« Reply #14 on: April 24, 2006, 08:15:14 PM »
BTW, Luis, it does work in 2006 but needs a refresh of some kind to update any text items already in the drawing.