Dtext 2 Mtext <selection order>
CADForums.net Forum Index CADForums.net
Discussion of AutoCAD and other CAD software.
 
 FAQFAQ   MemberlistMemberlist     RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 
Google
 
Web cadforums.net
Dtext 2 Mtext
Goto page Previous  1, 2
 
Post new topic   Reply to topic    CADForums.net Forum Index -> Customization
Author Message
T.Willey
Guest





Posted: Mon Jan 03, 2005 11:48 pm    Post subject: Re: Dtext 2 Mtext Reply with quote

Sorry. After you get that value (it is a variant) you need to change it to a safearray so that you can get the rubberband line when you pick your distance so you could then do

(setq MtPt1 (tmw:Var->Safe MtPt1))

Hope that is clear. If not, tell me what isn't and I will try and explain.

Tim

Back to top
T.Willey
Guest





Posted: Mon Jan 03, 2005 11:52 pm    Post subject: Re: Dtext 2 Mtext Reply with quote

Here you go. This is easier then me trying to tell you.

Tim

* watch for word wrap

(defun c:Dt2Mt (/ ActDoc ss TxtList TxtLine CurSpace MtPt1 MtDist othm)

(setq ActDoc (vla-get-ActiveDocument (vlax-get-Acad-Object)))
(vla-StartUndoMark ActDoc)
(setq othm (vla-GetVariable ActDoc "orthomode"))
(vla-SetVariable ActDoc "orthomode" 1)
(if (setq ss (ssget '((0 . "TEXT"))))
(progn
(setq TxtList (tmw:ss->Objlist ss))
(setq TxtList
(vl-sort
TxtList
'(lambda (a b)
(>
(cadr (tmw:Var->Safe (vla-get-InsertionPoint a)))
(cadr (tmw:Var->Safe (vla-get-InsertionPoint b)))
)
)
)
)
(setq MtPt1 (tmw:Var->Safe (vla-get-InsertionPoint (car TxtList)))) ;<- added this line
(foreach item TxtList
(if TxtLine
(setq TxtLine (strcat TxtLine " " (vla-get-TextString item)))
(setq TxtLine (vla-get-TextString item))
)
(vla-Delete item)
)
(setq CurSpace (GetCurrentSpace ActDoc))
; (setq MtPt1 (getpoint "\n Select starting point: ")) <- took out this line
(setq MtDist (getdist MtPt1 "\n Select width of Mtext: "))
(if MtDist
(vla-AddMText CurSpace (vlax-3d-point MtPt1) MtDist TxtLine)
)
)
)
(vla-SetVariable ActDoc "orthomode" othm)
(vla-EndUndoMark ActDoc)
(princ)
)
Back to top
Jason Piercey
Guest





Posted: Tue Jan 04, 2005 12:14 am    Post subject: Re: Dtext 2 Mtext Reply with quote

Hi Tim,

Perhaps I am not seeing something here but
doesn't this code accomplish the same thing?

(defun activeSpaceObject (document)
(vla-get-block
(vla-get-activelayout document)) )


--
Autodesk Discussion Group Facilitator



"T.Willey" <nospam@address.withheld> wrote in message
news:10631117.1104773047025.JavaMail.jive@jiveforum2.autodesk.com...
Quote:
Forgot you will need this one also.

Tim

(defun GetCurrentSpace (Doc / BlkCol SpaceList CurSpace ActSpace temp1)
; Returns the "block object" for the active space

<snip>

Back to top
T.Willey
Guest





Posted: Tue Jan 04, 2005 12:49 am    Post subject: Re: Dtext 2 Mtext Reply with quote

It appears so. Thanks Jason. It is always nice to learn the shorter ways to things.

Tim
Back to top
GaryDF
Guest





Posted: Tue Jan 04, 2005 12:55 am    Post subject: Re: Dtext 2 Mtext Reply with quote

Thanks

Here is my final version...

Gary


Code:

(defun c:D2M  (/ ActDoc ss TxtList TxtLine CurSpace MtPt1 MtDist othm)
  (princ "\n* Convert Dtext to Mtext <window select> *")
  (setq ActDoc (vla-get-ActiveDocument (vlax-get-Acad-Object)))
  (vla-StartUndoMark ActDoc)
  (setq othm (vla-GetVariable ActDoc "orthomode"))
  (vla-SetVariable ActDoc "orthomode" 1)
  (if (setq ss (ssget '((0 . "TEXT"))))
    (progn (setq TxtList (tmw:ss->Objlist ss))
           (setq TxtList
                  (vl-sort
                    TxtList
                    '(lambda (a b)
                       (> (cadr (tmw:Var->Safe (vla-get-InsertionPoint a)))
                          (cadr (tmw:Var->Safe (vla-get-InsertionPoint b)))))))
           (setq MtPt1 (tmw:Var->Safe (vla-get-InsertionPoint (car TxtList))))
    ;<- added this line
           (foreach
                  item  TxtList
             (if TxtLine
               (setq TxtLine (strcat TxtLine " " (vla-get-TextString item)))
               (setq TxtLine (vla-get-TextString item)))
             (vla-Delete item))
           (setq CurSpace (GetCurrentSpace ActDoc))
    ;  (setq MtPt1 (getpoint "\n Select starting point: "))  <- took out this
line
           ;(setq MtDist (getdist MtPt1 "\n Select width of Mtext: "))
           (setq MtDist (* (getvar "textsize") 20)) ;ADDED
           (if MtDist
             (vla-AddMText CurSpace (vlax-3d-point MtPt1) MtDist TxtLine))))
  (vla-SetVariable ActDoc "orthomode" othm)
  (vla-EndUndoMark ActDoc)
  (ARCH:MTLS 0.825) ;ADDED
  (princ))


"T.Willey" <nospam@address.withheld> wrote in message
news:21305209.1104778383944.JavaMail.jive@jiveforum2.autodesk.com...
Quote:
Here you go. This is easier then me trying to tell you.

Tim

* watch for word wrap

(defun c:Dt2Mt (/ ActDoc ss TxtList TxtLine CurSpace MtPt1 MtDist othm)

(setq ActDoc (vla-get-ActiveDocument (vlax-get-Acad-Object)))
(vla-StartUndoMark ActDoc)
(setq othm (vla-GetVariable ActDoc "orthomode"))
(vla-SetVariable ActDoc "orthomode" 1)
(if (setq ss (ssget '((0 . "TEXT"))))
(progn
(setq TxtList (tmw:ss->Objlist ss))
(setq TxtList
(vl-sort
TxtList
'(lambda (a b)
(
(cadr (tmw:Var->Safe (vla-get-InsertionPoint a)))
(cadr (tmw:Var->Safe (vla-get-InsertionPoint b)))
)
)
)
)
(setq MtPt1 (tmw:Var->Safe (vla-get-InsertionPoint (car TxtList)))) ;<- added
this line
(foreach item TxtList
(if TxtLine
(setq TxtLine (strcat TxtLine " " (vla-get-TextString item)))
(setq TxtLine (vla-get-TextString item))
)
(vla-Delete item)
)
(setq CurSpace (GetCurrentSpace ActDoc))
; (setq MtPt1 (getpoint "\n Select starting point: ")) <- took out this line
(setq MtDist (getdist MtPt1 "\n Select width of Mtext: "))
(if MtDist
(vla-AddMText CurSpace (vlax-3d-point MtPt1) MtDist TxtLine)
)
)
)
(vla-SetVariable ActDoc "orthomode" othm)
(vla-EndUndoMark ActDoc)
(princ)
)
Back to top
GaryDF
Guest





Posted: Tue Jan 04, 2005 12:59 am    Post subject: Re: Dtext 2 Mtext Reply with quote

Thanks

I'm learning more every day........

Gary


"wkiernan" <nospam@address.withheld> wrote in message
news:8003998.1104775380772.JavaMail.jive@jiveforum1.autodesk.com...
Quote:
The way I did it with a selection set of TEXT entities:

1.) take the first entity in the selection set, create a UCS relative to that
object (this is so you can sort text that is not at angle zero)

2.) go through the selection set, make an index list of sublists where the
first element of the sublist is the y-coordinate transformed from the world UCS

to the user UCS and the second element is the count
Quote:

3.) sort that list by the first element in each sublist, to sort by
y-coordinates

4.) now step through the index list and the second element of each sublist is
the index of the text entity

5.) restore your previous UCS

Here's a sample:

(defun C:SORTEXT()
(if (setq eset (ssget (list (cons 0 "TEXT"))))
(progn
(setq ecount (sslength eset) srtlst nil)
(command "ucs" "e" (ssname eset 0))
(while (>= (setq ecount (1- ecount)) 0)
(setq ename (ssname eset ecount)
edata (entget ename)
srtlst (cons (list (cadr (trans (cdr (assoc 10 edata)) 0 1)) ecount)
srtlst)
)
)
(setq srtlst (vl-sort srtlst (quote (lambda (e1 e2)(> (car e1)(car e2))))))
; at this point you've sorted the TEXT entities
; by y-coordinates, so do something with them
; in this example, print their text value
(foreach el srtlst
(princ (cdr (assoc 1 (entget (ssname eset (cadr el))))))
(princ "\n")
)
)
(princ "\nNo TEXT entities selected. ")
)
(command "ucs" "p")
(prin1)
)
Back to top
Jason Piercey
Guest





Posted: Tue Jan 04, 2005 1:01 am    Post subject: Re: Dtext 2 Mtext Reply with quote

You're welcome. I will also be revising my
toolbox function to use this method rather
than the way I was doing things.

--
Autodesk Discussion Group Facilitator



"T.Willey" <nospam@address.withheld> wrote in message
news:22862305.1104781799794.JavaMail.jive@jiveforum2.autodesk.com...
Quote:
It appears so. Thanks Jason. It is always nice to learn the shorter ways
to things.

Tim
Back to top
T.Willey
Guest





Posted: Tue Jan 04, 2005 1:09 am    Post subject: Re: Dtext 2 Mtext Reply with quote

Glad you got it to work the way you wanted it to.

Tim
Back to top
Josh Limas
Guest





Posted: Tue Jan 11, 2005 12:17 am    Post subject: Re: Dtext 2 Mtext Reply with quote

Hi Gary,

I thought this is a great routine, only I'm getting this message after selecting the
text ; error: An error has occurred inside the *error* functiontoo many arguments,
can you tell me why?  Thanks.

Josh

GaryDF wrote:

Quote:
Thanks

Here is my final version...

Gary

Code:

(defun c:D2M  (/ ActDoc ss TxtList TxtLine CurSpace MtPt1 MtDist othm)
  (princ "\n* Convert Dtext to Mtext <window select> *")
  (setq ActDoc (vla-get-ActiveDocument (vlax-get-Acad-Object)))
  (vla-StartUndoMark ActDoc)
  (setq othm (vla-GetVariable ActDoc "orthomode"))
  (vla-SetVariable ActDoc "orthomode" 1)
  (if (setq ss (ssget '((0 . "TEXT"))))
    (progn (setq TxtList (tmw:ss->Objlist ss))
           (setq TxtList
                  (vl-sort
                    TxtList
                    '(lambda (a b)
                       (> (cadr (tmw:Var->Safe (vla-get-InsertionPoint a)))
                          (cadr (tmw:Var->Safe (vla-get-InsertionPoint b)))))))
           (setq MtPt1 (tmw:Var->Safe (vla-get-InsertionPoint (car TxtList))))
    ;<- added this line
           (foreach
                  item  TxtList
             (if TxtLine
               (setq TxtLine (strcat TxtLine " " (vla-get-TextString item)))
               (setq TxtLine (vla-get-TextString item)))
             (vla-Delete item))
           (setq CurSpace (GetCurrentSpace ActDoc))
    ;  (setq MtPt1 (getpoint "\n Select starting point: "))  <- took out this
line
           ;(setq MtDist (getdist MtPt1 "\n Select width of Mtext: "))
           (setq MtDist (* (getvar "textsize") 20)) ;ADDED
           (if MtDist
             (vla-AddMText CurSpace (vlax-3d-point MtPt1) MtDist TxtLine))))
  (vla-SetVariable ActDoc "orthomode" othm)
  (vla-EndUndoMark ActDoc)
  (ARCH:MTLS 0.825) ;ADDED
  (princ))
Back to top
GaryDF
Guest





Posted: Tue Jan 11, 2005 12:47 am    Post subject: Re: Dtext 2 Mtext Reply with quote

Need this function:

;;;by: Peter Jamtgaard 2003
;;;usage (ARCH:MTLS 0.825)
(defun ARCH:MTLS (spght / sset factor cnt)
(setq SSET (ssget "x" (list (cons 0 "MTEXT")))
CNT 0)
(repeat (sslength SSET)
(vla-put-LineSpacingFactor
(vlax-ename->vla-object (ssname SSET CNT))
spght)
(setq CNT (1+ CNT)))
(princ))

Gary


"Josh Limas" <josh.limas@ggarch.com> wrote in message
news:41E2D4BA.883441D@ggarch.com...
Quote:
Hi Gary,

I thought this is a great routine, only I'm getting this message after
selecting the
text ; error: An error has occurred inside the *error* functiontoo many
arguments,
can you tell me why? Thanks.

Josh

GaryDF wrote:

Thanks

Here is my final version...

Gary

Code:

(defun c:D2M (/ ActDoc ss TxtList TxtLine CurSpace MtPt1 MtDist othm)
(princ "\n* Convert Dtext to Mtext <window select> *")
(setq ActDoc (vla-get-ActiveDocument (vlax-get-Acad-Object)))
(vla-StartUndoMark ActDoc)
(setq othm (vla-GetVariable ActDoc "orthomode"))
(vla-SetVariable ActDoc "orthomode" 1)
(if (setq ss (ssget '((0 . "TEXT"))))
(progn (setq TxtList (tmw:ss->Objlist ss))
(setq TxtList
(vl-sort
TxtList
'(lambda (a b)
(> (cadr (tmw:Var->Safe (vla-get-InsertionPoint a)))
(cadr (tmw:Var->Safe (vla-get-InsertionPoint b)))))))
(setq MtPt1 (tmw:Var->Safe (vla-get-InsertionPoint (car TxtList))))
;<- added this line
(foreach
item TxtList
(if TxtLine
(setq TxtLine (strcat TxtLine " " (vla-get-TextString item)))
(setq TxtLine (vla-get-TextString item)))
(vla-Delete item))
(setq CurSpace (GetCurrentSpace ActDoc))
; (setq MtPt1 (getpoint "\n Select starting point: ")) <- took out this
line
;(setq MtDist (getdist MtPt1 "\n Select width of Mtext: "))
(setq MtDist (* (getvar "textsize") 20)) ;ADDED
(if MtDist
(vla-AddMText CurSpace (vlax-3d-point MtPt1) MtDist TxtLine))))
(vla-SetVariable ActDoc "orthomode" othm)
(vla-EndUndoMark ActDoc)
(ARCH:MTLS 0.825) ;ADDED
(princ))

Back to top
Kent Cooper, AIA
Guest





Posted: Tue Jan 11, 2005 12:59 am    Post subject: Re: Dtext 2 Mtext Reply with quote

Does Express Tools' "Convert Text to Mtext" not do what you want? Or does
this do it in some way that's different or better? If not, the Express Tool
should get you away from the error message.

[ By the way, there's no such entity type as "Dtext" -- that's just a
different means of putting in Text, in a Dynamic way to make it easier to
see what you're getting as you type it in. But the things you want to
convert to Mtext are not Dtext, they're Text, as you can see from the
(ssget) item in the code.]
--
Kent Cooper, AIA


"Josh Limas" wrote...
Quote:
Hi Gary,

I thought this is a great routine, only I'm getting this message after
selecting the
text ; error: An error has occurred inside the *error* functiontoo many
arguments,
can you tell me why? Thanks.

Josh

GaryDF wrote:

Thanks

Here is my final version...

Gary

Code:

(defun c:D2M (/ ActDoc ss TxtList TxtLine CurSpace MtPt1 MtDist othm)
(princ "\n* Convert Dtext to Mtext <window select> *")
(setq ActDoc (vla-get-ActiveDocument (vlax-get-Acad-Object)))
(vla-StartUndoMark ActDoc)
(setq othm (vla-GetVariable ActDoc "orthomode"))
(vla-SetVariable ActDoc "orthomode" 1)
(if (setq ss (ssget '((0 . "TEXT"))))
(progn (setq TxtList (tmw:ss->Objlist ss))
(setq TxtList
(vl-sort
TxtList
'(lambda (a b)
(> (cadr (tmw:Var->Safe (vla-get-InsertionPoint a)))
(cadr (tmw:Var->Safe (vla-get-InsertionPoint b)))))))
(setq MtPt1 (tmw:Var->Safe (vla-get-InsertionPoint (car TxtList))))
;<- added this line
(foreach
item TxtList
(if TxtLine
(setq TxtLine (strcat TxtLine " " (vla-get-TextString item)))
(setq TxtLine (vla-get-TextString item)))
(vla-Delete item))
(setq CurSpace (GetCurrentSpace ActDoc))
; (setq MtPt1 (getpoint "\n Select starting point: ")) <- took out this
line
;(setq MtDist (getdist MtPt1 "\n Select width of Mtext: "))
(setq MtDist (* (getvar "textsize") 20)) ;ADDED
(if MtDist
(vla-AddMText CurSpace (vlax-3d-point MtPt1) MtDist TxtLine))))
(vla-SetVariable ActDoc "orthomode" othm)
(vla-EndUndoMark ActDoc)
(ARCH:MTLS 0.825) ;ADDED
(princ))
Back to top
 
Post new topic   Reply to topic    CADForums.net Forum Index -> Customization All times are GMT
Goto page Previous  1, 2
Page 2 of 2

 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum




Windows Server DSP VoIP Electronics New Topics
Contact Us
Powered by phpBB