Jump to content

Mtext Align and Mtext Width 0


SLW210

Recommended Posts

Looking for a code to line up Mtext/Text sometimes vertical and sometimes horizontal and sometimes set the justification.

 

Also I need to set Mtext defined width 0 (or just reduce it to the longest row or Text is fine ,but, if I explode the Mtext, it doesn't maintain the Justification.

 

P.S. I have Joe Burke's ShrinkwrapMText v2a.lsp, but I get (error: bad argument type: lentityp nil), I haven't looked into debugging it yet.

 

I also have MtextColumnsOffZeroWidth.lsp by BlackBox that I haven't tried yet.

 

I am more in need of aligning things.

 

In the example, I have already aligned manually some of the mtext, but manually is taking a while.

 

These started as scanned PDFs, I am converting the raster text with Raster Design and tracing the plines. When converting the raster text the locations are not accurate and though you can set justification the options are Left, Center and Right, which defaults to TOP and when I do a drawing I like to make them neat and align as much text as possible.

 

In case you are wondering, these are electrical diagrams and all in Modelspace.

MText Align-Mtext Width 0.dwg

Link to comment
Share on other sites

Not sure which text but if its the 1-41 using get-closestpointo should do the trick. You could also select and sort on  Y replace X with a fixed value. also replace Y with a fixed increment value. Using a start end point how many etc. 

 

I think found some #12/A/IR match yellow line. Tested on the 2 examples and 1-41.

 

; simple align text to line
; By AlanH July 2024

; align text option 1 may need alt2 alt3 etc
(defun c:alt1 ( / ss x )

(while (setq ent (car (entsel "\nSelect a line object ")))
 (setq obj (vlax-ename->vla-object ent))
 (setq ss (ssget '((0 . "*TEXT"))))

 (if (= ss nil)(progn (alert "you have not picked any M or text objects \nwill now exit")(exit)))

 (repeat (setq x (sslength ss))
  (setq obj2 (vlax-ename->vla-object (ssname ss (setq x (- x 1)))))
  (setq pt1 (vlax-get obj2 'insertionpoint ))
  (setq pt2 (vlax-curve-getclosestpointto obj pt1))
  (vla-move obj2 pt1 pt2)
 )

)

(princ)
)

 

image.png.f20cd506a5bebb9f9e999ef8106e7d62.png

 

Re alignment problems if you can provide raw text that needs fixing and the options to align. A quick answer is the 9 positions 1-9 for text as a number for me as per image either option probably do a 3x3 dcl.

 

image.png.e996e987ac9fcd4343deba40934beaf3.png

 

Thinking more if normally Hor or Ver could just select text and use correct X or Y for all text no need for line say use 1st text for that position. 

Edited by BIGAL
  • Thanks 1
Link to comment
Share on other sites

Had another go this may be useful for justification.

 

(defun wow ( / fo dcl_id fname x)
(setq fo (open (setq fname (vl-filename-mktemp "" "" ".dcl")) "w"))

(write-line "AHtxtpos : dialog 	{" fo)
(write-line "	label =\"Please Choose \" ;" fo)
(write-line "	: column	{" fo)
(write-line "	: boxed_radio_row	{" fo)
(write-line " width = 24 ;" fo)
(write-line "	: radio_button	{" fo)
(write-line "key = \"Rb1\";" fo)
(write-line "label = \"Top L\";" fo)
(write-line "	}" fo)
(write-line "	: radio_button	{" fo)
(write-line "key = \"Rb2\";" fo)
(write-line "label = \"Top Mid\";" fo)
(write-line "	}" fo)
(write-line "	: radio_button	{" fo)
(write-line "key = \"Rb3\";" fo)
(write-line "label = \"Top R\";" fo)
(write-line "	}" fo)
(write-line "	}" fo)
(write-line "spacer_1 ;" fo)
(write-line "	: boxed_radio_row	{" fo)
(write-line "	: radio_button	{" fo)
(write-line "key = \"Rb4\";" fo)
(write-line "label = \"Mid L\";" fo)
(write-line "	}" fo)
(write-line "	: radio_button	{" fo)
(write-line "key = \"Rb5\";" fo)
(write-line "label = \"Center\";" fo)
(write-line "	}" fo)
(write-line "	: radio_button	{" fo)
(write-line "key = \"Rb6\";" fo)
(write-line "label = \"Mid R\";" fo)
(write-line "	}" fo)
(write-line "	}" fo)
(write-line "spacer_1 ;" fo)
(write-line "	: boxed_radio_row	{" fo)
(write-line "	: radio_button	{" fo)
(write-line "key = \"Rb7\";" fo)
(write-line "label = \"Bot L \";" fo)
(write-line "	}" fo)
(write-line "spacer_1 ;" fo)
(write-line "	: radio_button	{" fo)
(write-line "key = \"Rb8\";" fo)
(write-line "label = \"Bot mid\";" fo)
(write-line "	}" fo)
(write-line "	: radio_button	{" fo)
(write-line "key = \"Rb9\";" fo)
(write-line "label = \"Bot R\";" fo)
(write-line "	}" fo)
(write-line "	}" fo)
(write-line "spacer_1 ;" fo)
(write-line "	ok_cancel;" fo)
(write-line "	}" fo)
(write-line "	}" fo)

(close fo)

(setq dcl_id (load_dialog fname))
(if (not (new_dialog "AHtxtpos" dcl_id) )
(exit)
)
(set_tile "Rb1" "1")
(setq x 1)
(repeat 9
(setq k (strcat "Rb" (rtos x 2 0)))
(action_tile k  (strcat "(setq but " (rtos x 2 0) ")" "(done_dialog)"))
(setq x (+ x 1))
)
(action_tile "accept" "(done_dialog)")
(start_dialog)
(unload_dialog dcl_id)

(vl-file-delete fname)

(cond
((= but 1)(setq pos "TL"))
((= but 2)(setq pos "TM"))
((= but 3)(setq pos "TR"))
((= but 4)(setq pos "LM"))
((= but 5)(setq pos "Cen"))
((= but 6)(setq pos "RM"))
((= but 7)(setq pos "BL"))
((= but 8)(setq pos "BM"))
((= but 9)(setq pos "BR"))
)


(princ)
)
(wow)

 

image.png.9ba60e9aa7d62f1b38addc06ad6430a0.png

Edited by BIGAL
  • Thanks 1
Link to comment
Share on other sites

I need most of the text aligned with (but not on) the nearest line (wire) unless an object forces it off more than the others.

 

I'll check those out shortly, but you appear to have the right idea. The red and yellow lines in the drawing are to show alignment point, I am trying to eliminate making lines everywhere to align with. I would just like to be able to click a start text/Mtext and align them and match justification with the first text.

 

 

Mtext Before 1.png

Mtext After 1.png

Link to comment
Share on other sites

The command TextAlign is working well enough for now for aligning, I just have to set Justification correctly as I create the text, then when I go to align select the alignment justification.

 

With all of the computer issues around the globe Friday I was pressed for time explaining things, my apologies.

Link to comment
Share on other sites

One idea is pick text take 1st in selection just ask horizontal Orr vertical and rest align wth X or Y on iPad now maybe later

Link to comment
Share on other sites

That's somewhat how TextAlign works, except to change things you have to go right-click, Options or alignment, then pick what you need.

 

For some reason doing a lot of different alignments with TextAlign is a pain to continually switch directions and justifications. 

 

I do have an old LISP from Alan J. Thompson that sets shortcuts for the Mtext justification, this is still taking a longer time than I think is necessary.

 

I also have an old LISP from Hallex (a.k.a. fixo) that centers Mtext in a rectangle and sets to middle center justification. That has helped.

 

The example I posted is one of the simpler ones.

 

No worries, I'll get it done. I need to try to find time to work on a solution as well. 

 

This is a set of 22 Sheets, once I do this, they will want lots more scanned PDFs converted would be my expectation.

 

You would think Raster Design would better deal with these issues, it has been around a long time now. Though I am glad it does pretty good at converting the texts, some of them are indexes.

 

For now job security. Thanks for looking at the issue.

 

Link to comment
Share on other sites

An idea is just pick mtext compare the X max value compared to say control text also do same with Y, if Y max is small then text is horizontal if Y max is big then text is vertical. 

 

Will try to do something, will test with text on angle have an idea maybe use a UCS or at worse rotate dwg, then revert back.

 

Its almost fishing club time code name for a few beers, yes the fish get bigger after a couple, maybe later tonight if some one else does not jump in.

 

Can you post a pre sample dwg including non justified text. Maybe look at how to speed up the justification. 

 

Lastly I dont think can automate past select, select, next layout unfortunately. Get something 1st then look at how to do big selection.

 

Can you post the Fixo lisp, have used a few of his and they are very good. Maybe can speed up.

 

Side note  600 mtext, left top justify -> Middle centre about 1.5 seconds. The text will move a little bit. Maybe acceptable ?

 

(setq ss (ssget "X" (list (cons 0 "MTEXT")(cons 410 "Model"))))
(repeat (setq x (sslength ss))
(setq obj (vlax-ename->vla-object (ssname ss (setq x (- x 1)))))
(vlax-put obj 'AttachmentPoint 5)
)

 

 

 

Edited by BIGAL
Link to comment
Share on other sites

I can justify pretty fast with the Shortcut Code from alanjt found HERE.  As mentioned by fixo in that thread, there is JUSTIFYTEXT command as well. Those don't seem to move the text position, but movement would be okay before aligning them anyway.

 

;;; Justification Macros
;;;
;;; https://www.cadtutor.net/forum/topic/35569-text-justification-lisp/?do=findComment&comment=289008
;;;
;;; BY alanjt (a.k.a. Alan J. Thompson)
;;;
;;; Customized By SLW210
;;;

(defun _justifyIt (justify title / ss)
 (princ (strcat "\nSelect *Text to " title " justify: "))
 (if (setq ss (ssget "_:L" '((0 . "ATTDEF,MTEXT,TEXT"))))
   (command "_.justifytext" ss "" justify)
 )
 (princ)
)

(defun c:MCe (/) (_justifyIt "_MC" "Middle Center"))
(defun c:MLe (/) (_justifyIt "_ML" "Middle Left"))
(defun c:MRi (/) (_justifyIt "_MR" "Middle Right"))
(defun c:BCe (/) (_justifyIt "_BC" "Bottom Center"))
(defun c:BRi (/) (_justifyIt "_BR" "Bottom Right"))
(defun c:BLe (/) (_justifyIt "_BL" "Bottom Left"))
(defun c:TLe (/) (_justifyIt "_TL" "Top Left"))
(defun c:TRi (/) (_justifyIt "_TR" "Top Right"))
(defun c:TCe (/) (_justifyIt "_TC" "Top Center"))

 

Your codes look promising, I'll try to work on Codes after I get more Raster Text converted and get a new unclean drawing on here, I've been cleaning up as I go, so far. 

 

Looking to speed up TEXTALIGN command at a minimum. It's pretty clunky if you have lots of aligning to do of different justifications. Help | TEXTALIGN (Command) | 

 

So basically, Select Texts/Mtexts to be aligned, Select the Text/Mtext to match justification and to align with and/or select the desired justification, then with mouse or quickly choose horizontal or vertical (I can manage without the oblique). 

 

Raster Design OLE can set justification, Left ,Right, Center, but,  they are all set to TOP, I just have to select it each time, you can also select the text height or automatic, which is random.

 

I also use a lot of MatchProp, but it moves the text, sometimes a lot. As long as visually everything appears aligned, I'm good with that.

 

Either scanning of the PDFs or originally created, on some of the sheets the texts weren't aligned very well, IMO.

 

Would it be of use to supply the raster file, I use TIFF? I'll need to scrub confidential information, but it's doable.

Link to comment
Share on other sites

Maybe just wblock out some bits and insert into a single sample dwg.

 

You can use the dcl above then only need 1 defun command for justification pick. Maybe write the dcl and save, then no need to continually write it just change the mk-temp to a file name. May speed up things. 

 

Had another go pick a single text as the reference, then select all text, input Vertical or Horizontal. 

 

One issue was where I picked a point and moved others but they had different justifications. 

(defun c:alt1 ( / ss x Y k ans)

(if (not AH:Butts)(load "Multi Radio buttons.lsp"))
(if (= ahdef nil)(setq ahdef 1))
(setq oldsnap (getvar 'osmode))
(setvar 'osmode 0)

(while (setq ent (car (entsel "\nPick text for alignment reference point Enter to exit ")))

(setq ans (ah:butts ahdef "h"  '("Horizontal or vertical " "Hor " "Ver"))) ; ans holds the button picked value
(setq ahdef but)

(setq pt (cdr (assoc 10 (entget ent))))
(setq X (car pt) Y (cadr pt))
(prompt "\nSelect text ")
(setq ss (ssget '((0 . "*TEXT"))))


(if (= ss nil)
(progn (alert "You have not selected anything will now exit")(exit))
)

(repeat (setq k (sslength ss))
(setq obj (vlax-ename->vla-object (ssname ss (setq k (- k 1)))))
(setq ptn (vlax-get obj 'Insertionpoint))
(if (= ahdef 1)
(setq Ptn (list (car ptn) Y ))
(setq Ptn (list X (cadr ptn)))
)m 
(vlax-put obj 'insertionpoint ptn)
)

)
(setvar 'osmode 0)

(princ)
)
(C:alt1)

 

Multi radio buttons.lsp

 

The multi radio should remember last Hor or ver, so can do enter if it doesn't let me know was a bug in a version I posted here.

 

Still thinking about auto Ver or Hor.

Edited by BIGAL
  • Thanks 1
Link to comment
Share on other sites

I believe my current method is as fast as this will get, but I am hopeful, I am quite busy at work this week.

 

I'll try to look at what you have posted so far when time allows.

 

Thanks for your hard work, looks promising, just a few seconds here and there will help.

 

Converting from Raster to Vector is time consuming, if I try too much at one time, I spend more time reviewing for errors and correcting.

 

I included the TIFF so you can see the image I am working on.

 

Text Align Test - Standard.zip

Link to comment
Share on other sites

Picked an easy group for this video. The while means can keep going.

 

Can see why the justification is a problem, mid top v's mid bot.

 

aligntext.gif

 

Changed a few others and works reasonably well, not sure if can be sped up more.

Edited by BIGAL
Link to comment
Share on other sites

I found AlignAll.lsp , he said he had a DCL version but I can't find it, and also TextAlign.lsp by Charles Alan Butler (CAB) on the swamp.

 

LeeMac has a nice one. DynamicTextAlignV1-6.lsp.

 

So far this old one by Tony Hotchkiss is pretty good Align Entities: ALIGNIT.LSP | CAD Tips (cadalyst.com) It has a DCL and it works well for the vertical texts as well.

 

Nobody is setting the justification, though I can quickly do that with the shortcut LISP from alanjt.

 

The popup with the radio buttons in your video is spot on towards what I want for interaction and setting things up.

 

Speed it up is relative term, I just want an easy way to adjust alignment and justification on the fly.

 

Would be easier all around if Raster Design allowed a full selection of justifications, seems the program has been around quite some time with little improvements.

 

Link to comment
Share on other sites

Should be able to set justification as part of the sequence say adding in Alan Thompson's set alignment. Ie one code. 

 

Did find in my V24 Bricscad no "justifytext" a nuisance. But if using Acad no probs.

 

Latest version has Alan's code.

 

Code removed see below

 

 

 

 

Edited by BIGAL
Link to comment
Share on other sites

I'll check it out next week when I get back to work.

 

That was my thoughts exactly, combine with the align macro LISP.

 

I realize most people really don't need these options, but if you use Raster Design on a raster text heavy file, the conversions take a while themselves, then organizing text/mtext really lengthens that time more than you think. Lining up 2 or 3 texts take up a lot of time.

 

If Raster Design would work better, i.e., not having all of the justification options for one and not exactly placing the text/mtext where the raster was.

 

It is still faster than redoing it all from tracing manually.

 

I'll have to buy a few beers for several people it seems. I am not sure I could have LISPed this from scratch.

 

Thanks for your work on this. I have a pressing project to complete Monday, though I might have some time Monday to work on codes and testing for this project.

Link to comment
Share on other sites

I am getting "Pick text for alignment reference point Enter to exit ; error: AutoCAD.Application: Incorrect number of elements in SafeArray" for...

 

(vlax-put obj 'insertionpoint ptn)

 

Link to comment
Share on other sites

I will double check what is posted is Ok. 

 

 

Found a command TJUST that should work in Acad and Bricscad. If not working Acad use _.justifytext.

 

(command "TJUST" ss "" "MC")

 

Found a problem in the while fixed that. Hopefully correct now. Did a little bit of reorganising code also. Just did 3 columns of text worked ok.

 

; https://www.cadtutor.net/forum/topic/88262-mtext-align-and-mtext-width-0/

; simple align text to line
: By AlanH July 2024

;;; Justification Macros
;;;
;;; https://www.cadtutor.net/forum/topic/35569-text-justification-lisp/?do=findComment&comment=289008
;;;
;;; BY alanjt (a.k.a. Alan J. Thompson)
;;;
;;; Customized By SLW210
;;;

(defun c:alt1 ( / _justifyIt ent fo x Y k ans but ss oldsnap pt obj ptn)

(defun _justifyIt (justify title / )
 (princ (strcat "\nSelect *Text to " title " justify: "))
 (if (setq ss (ssget '((0 . "ATTDEF,MTEXT,TEXT"))))
   (command "_.TJUST" ss "" justify)
 )
 (princ)
)


(while (setq ent (car (entsel "\nPick single text for alignment Enter to exit ")))

(if (= fname nil)
(progn
(setq fo (open (setq fname (vl-filename-mktemp "" "" ".dcl")) "w"))

(write-line "AHtxtpos : dialog 	{" fo)
(write-line "	label =\"Please Choose \" ;" fo)
(write-line "	: column	{" fo)
(write-line "	: boxed_radio_row	{" fo)
(write-line " width = 24 ;" fo)
(write-line "	: radio_button	{" fo)
(write-line "key = \"Rb1\";" fo)
(write-line "label = \"Top L\";" fo)
(write-line "	}" fo)
(write-line "	: radio_button	{" fo)
(write-line "key = \"Rb2\";" fo)
(write-line "label = \"Top Mid\";" fo)
(write-line "	}" fo)
(write-line "	: radio_button	{" fo)
(write-line "key = \"Rb3\";" fo)
(write-line "label = \"Top R\";" fo)
(write-line "	}" fo)
(write-line "	}" fo)
(write-line "spacer_1 ;" fo)
(write-line "	: boxed_radio_row	{" fo)
(write-line "	: radio_button	{" fo)
(write-line "key = \"Rb4\";" fo)
(write-line "label = \"Mid L\";" fo)
(write-line "	}" fo)
(write-line "	: radio_button	{" fo)
(write-line "key = \"Rb5\";" fo)
(write-line "label = \"Center\";" fo)
(write-line "	}" fo)
(write-line "	: radio_button	{" fo)
(write-line "key = \"Rb6\";" fo)
(write-line "label = \"Mid R\";" fo)
(write-line "	}" fo)
(write-line "	}" fo)
(write-line "spacer_1 ;" fo)
(write-line "	: boxed_radio_row	{" fo)
(write-line "	: radio_button	{" fo)
(write-line "key = \"Rb7\";" fo)
(write-line "label = \"Bot L \";" fo)
(write-line "	}" fo)
(write-line "spacer_1 ;" fo)
(write-line "	: radio_button	{" fo)
(write-line "key = \"Rb8\";" fo)
(write-line "label = \"Bot mid\";" fo)
(write-line "	}" fo)
(write-line "	: radio_button	{" fo)
(write-line "key = \"Rb9\";" fo)
(write-line "label = \"Bot R\";" fo)
(write-line "	}" fo)
(write-line "	}" fo)
(write-line "spacer_1 ;" fo)
(write-line "	ok_cancel;" fo)
(write-line "	}" fo)
(write-line "	}" fo)

(close fo)
)
)

(setq dcl_id (load_dialog fname))
(if (not (new_dialog "AHtxtpos" dcl_id) )
(exit)
)
(set_tile "Rb1" "1")
(setq x 1)
(repeat 9
(setq k (strcat "Rb" (rtos x 2 0)))
(action_tile k  (strcat "(setq but " (rtos x 2 0) ")" "(done_dialog)"))
(setq x (+ x 1))
)
(action_tile "accept" "(done_dialog)")
(start_dialog)
(unload_dialog dcl_id)

(cond
((= but 1)(_justifyIt "_TL" "Top Left"))
((= but 2)(_justifyIt "_TC" "Top Center"))
((= but 3)(_justifyIt "_TR" "Top Right"))
((= but 4)(_justifyIt "_ML" "Middle Left"))
((= but 5)(_justifyIt "_MC" "Middle Center"))
((= but 6)(_justifyIt "_MR" "Middle Right"))
((= but 7)(_justifyIt "_BL" "Bottom Left"))
((= but 8)(_justifyIt "_BC" "Bottom Center"))
((= but 9)(_justifyIt "_BR" "Bottom Right"))
)

(if (not AH:Butts)(load "Multi Radio buttons.lsp"))
(if (= ahdef nil)(setq ahdef 1))
(setq oldsnap (getvar 'osmode))
(setvar 'osmode 0)

(setq ans (ah:butts ahdef "h"  '("Horizontal or vertical " "Hor " "Ver"))) ; ans holds the button picked value
(setq ahdef but)

(setq pt (cdr (assoc 10 (entget ent))))
(setq X (car pt) Y (cadr pt))

(if (= ss nil)
(progn (alert "You have not selected anything will now exit")(exit))
)

(repeat (setq k (sslength ss))
 (setq obj (vlax-ename->vla-object (ssname ss (setq k (- k 1)))))
 (setq ptn (vlax-get obj 'Insertionpoint))
 (if (= ahdef 1)
  (setq ptn (list (car ptn) Y 0.0))
  (setq ptn (list X (cadr ptn) 0.0))
 )
 (vlax-put obj 'insertionpoint ptn)
) ; repeat

) ; while


(vl-file-delete fname)
(setvar 'osmode oldsnap)

(princ)
)
(C:alt1)

 

Re Error message got similar at another post, forums/autodesk, I think it may be I am using Bricscad and it may accept X,Y as a point but Acad wants X,Y,Z. I have added the z=0 to pnt please let me know if that fixes it.

 

 

 

 

Edited by BIGAL
  • Thanks 1
Link to comment
Share on other sites

Works on AutoCAD 2000i at home.

 

I'll test at work tomorrow.

 

Sorry I am not have a lot of free time to work on the coding.

 

I was trying to find an alternate to Justifytext to use on my 2000i at home.

 

Good find on TJUST.

 

You've done well, I need to practice VLISP more.

 

I should have caught the X,Y,Z though.

Link to comment
Share on other sites

Mo worries I know what it's like to be to busy, I can not see any fast way of doing this unfortunately. I will post separate about a "Is it vertical or horizontal text" The Swamp has a section Challenges which is a good place for snippet of code answers.

Link to comment
Share on other sites

Just had time to do a quick test and a little  tweaking, I have this working in AutoCAD 2024. It initially wasn't Justifying the Mtext.

 

You can compare it, I tweaked and then undid a few things, for some reason I would get TJUST unknown command, though TJUST works by itself.

 

If I have time to code next week I am going to add something to shrink-wrap the text as well.

 

Thanks for all of the work BIGAL!!

 

;;; Align and Justify Text/Mtext
;;;
;;; https://www.cadtutor.net/forum/topic/88262-mtext-align-and-mtext-width-0/
;;;


; simple align text to line
: By AlanH July 2024

;;; Justification Macros
;;;
;;; https://www.cadtutor.net/forum/topic/35569-text-justification-lisp/?do=findComment&comment=289008
;;;
;;; BY alanjt (a.k.a. Alan J. Thompson)
;;;
;;; Customized By SLW210
;;;

(defun c:alt1 ( / _justifyIt ent fo x Y k ans but ss oldsnap pt obj ptn)


(defun _justifyIt (justify title / )
 (princ (strcat "\nSelect *Text to " title " justify: "))
 (if (setq ss (ssget '((0 . "ATTDEF,MTEXT,TEXT"))))
   (command "_.JUSTIFYTEXT" ss "" justify)
 )
 (princ)
)


(while (setq ent (car (entsel "\nPick single text for alignment Enter to exit ")))

(if (= fname nil)
(progn
(setq fo (open (setq fname (vl-filename-mktemp "" "" ".dcl")) "w"))


(write-line "AHtxtpos : dialog 	{" fo)
(write-line "	label =\"Please Choose \" ;" fo)
(write-line "	: column	{" fo)
(write-line "	: boxed_radio_row	{" fo)
(write-line " width = 24 ;" fo)
(write-line "	: radio_button	{" fo)
(write-line "key = \"Rb1\";" fo)
(write-line "label = \"Top L\";" fo)
(write-line "	}" fo)
(write-line "	: radio_button	{" fo)
(write-line "key = \"Rb2\";" fo)
(write-line "label = \"Top Mid\";" fo)
(write-line "	}" fo)
(write-line "	: radio_button	{" fo)
(write-line "key = \"Rb3\";" fo)
(write-line "label = \"Top R\";" fo)
(write-line "	}" fo)
(write-line "	}" fo)
(write-line "spacer_1 ;" fo)
(write-line "	: boxed_radio_row	{" fo)
(write-line "	: radio_button	{" fo)
(write-line "key = \"Rb4\";" fo)
(write-line "label = \"Mid L\";" fo)
(write-line "	}" fo)
(write-line "	: radio_button	{" fo)
(write-line "key = \"Rb5\";" fo)
(write-line "label = \"Center\";" fo)
(write-line "	}" fo)
(write-line "	: radio_button	{" fo)
(write-line "key = \"Rb6\";" fo)
(write-line "label = \"Mid R\";" fo)
(write-line "	}" fo)
(write-line "	}" fo)
(write-line "spacer_1 ;" fo)
(write-line "	: boxed_radio_row	{" fo)
(write-line "	: radio_button	{" fo)
(write-line "key = \"Rb7\";" fo)
(write-line "label = \"Bot L \";" fo)
(write-line "	}" fo)
(write-line "spacer_1 ;" fo)
(write-line "	: radio_button	{" fo)
(write-line "key = \"Rb8\";" fo)
(write-line "label = \"Bot mid\";" fo)
(write-line "	}" fo)
(write-line "	: radio_button	{" fo)
(write-line "key = \"Rb9\";" fo)
(write-line "label = \"Bot R\";" fo)
(write-line "	}" fo)
(write-line "	}" fo)
(write-line "spacer_1 ;" fo)
(write-line "	ok_cancel;" fo)
(write-line "	}" fo)
(write-line "	}" fo)

(close fo)
)
)

(setq dcl_id (load_dialog fname))
(if (not (new_dialog "AHtxtpos" dcl_id) )
(exit)
)
(set_tile "Rb1" "1")
(setq x 1)
(repeat 9
(setq k (strcat "Rb" (rtos x 2 0)))
(action_tile k  (strcat "(setq but " (rtos x 2 0) ")" "(done_dialog)"))
(setq x (+ x 1))
)
(action_tile "accept" "(done_dialog)")
(start_dialog)
(unload_dialog dcl_id)

(cond
((= but 1)(_justifyIt "_TL" "Top Left"))
((= but 2)(_justifyIt "_TC" "Top Center"))
((= but 3)(_justifyIt "_TR" "Top Right"))
((= but 4)(_justifyIt "_ML" "Middle Left"))
((= but 5)(_justifyIt "_MC" "Middle Center"))
((= but 6)(_justifyIt "_MR" "Middle Right"))
((= but 7)(_justifyIt "_BL" "Bottom Left"))
((= but 8)(_justifyIt "_BC" "Bottom Center"))
((= but 9)(_justifyIt "_BR" "Bottom Right"))
)

(if (not AH:Butts)(load "Multi Radio buttons.lsp"))
(if (= ahdef nil)(setq ahdef 1))
(setq oldsnap (getvar 'osmode))
(setvar 'osmode 0)

(setq ans (ah:butts ahdef "h"  '("Horizontal or vertical " "Hor " "Ver"))) ; ans holds the button picked value
(setq ahdef but)

(setq pt (cdr (assoc 10 (entget ent))))
(setq X (car pt) Y (cadr pt))

(if (= ss nil)
(progn (alert "You have not selected anything will now exit")(exit))
)

(repeat (setq k (sslength ss))
 (setq obj (vlax-ename->vla-object (ssname ss (setq k (- k 1)))))
 (setq ptn (vlax-get obj 'Insertionpoint))
 (if (= ahdef 1)
  (setq ptn (list (car ptn) Y 0.0))
  (setq ptn (list X (cadr ptn) 0.0))
 )
 (vlax-put obj 'insertionpoint ptn)
) ; repeat

) ; while


(vl-file-delete fname)
(setvar 'osmode oldsnap)

(princ)
)
(C:alt1)

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...