AutoCAD Visual LISP / AutoLISP :: Sorting Multi Line Text In Alphabetic Order
Apr 23, 2013
I required a lisp for sorting Multiline text in alphabetic order. (Ascending and Descending)
For example in my drawing it contains lot of Mtexts having multi rows. I need to sort texts inside Mtext. Like PDC-012, DAG-012, AAG-096. I need that Mtext should be AAG-096,DAG-012,PDC-012.
I want to entmake a block with a multiline attribute. Entmaking the block definition works fine, but what do I code for the Multiline Attribute? Should it be coded (0 . "MTEXT") instead of (0 . "ATTRIB")? I know (101 . "Embedded Object") does not work. What other codes need to be included?
I am able to insert multi line text into the Drawing Properties Summaryinfo standard field "comments" by using string concatenation in VBA by using "mytext" & vbLF & vbCR "mytext".
But I can't find a way that works in autolisp. This code does not work.
Is there a way to modify the text insertion point of multileaders using lisp? We have a problem with some of our multileaders getting a landing distance set to a negative value. My lisp routine will correct these to a default value, but then the text jumps a bit. If I could get the insertion point prior to changing the landing distance then I could restore that point after changing the landing distance.
;;-------------------------------------------------------------------------------------------------(defun c:zld (/ e th dogleg doglegllength sf ss c mlss mlcount) (setqss (ssget (ssget "X" (list (cons 0 "MULTILEADER"))))DWATxtHgt (getvar "userr1")sf 1dogleg (/ 3 32.0)th (if dwatxthgt dwatxthgt dogleg)c 0mlcount 0mlss (ssadd)) (IF ss (while (< c (sslength ss)) (setq e (vlax-ename->vla-object (ssname ss c)) c (1+ c) ) (= (vla-get-ObjectName e) "AcDbMLeader") (progn;;change the dogleglength if
I'm trying to write a lisp routine to create a two line MLEADER but i can only get one line of text. Creating the MLEADER manually from the command line i just have to hit enter after the first line of text to add a second line. How would i do this in a lisp routine?
I found a lisp for counting of selected block in a table drawing, but I can not remove the bottom line of this lisp that displays "total" blocks. How to remove this line from "total" that is created in the last row of the table that lisp.
lisp : ========================================
(defun c:TABL (/ blk_id blk_len blk_name blks ent h header_lsp height i j TOTAL len0 lst_blk msp pt row ss str tblobj width width1 width2 x y )
I have a custom command that I can initiate (c:TxtE). The function starts running but I need to begin adding several inputs at the command line following this. (ex: "4" "all" "" "oldtext" "newtext"). How do i do that within lisp once the custom command has already begun? If I need to modify the function how would i pass all these as optional type variables?
I am writing a program that allows the user to select hatched areas in a drawing and return the quantity, area, and the weight for the equivalent areas covered by tread plate.
My goal is to insert the data with text at a point of the user's choosing, so the end result is a text object in model space that looks like this:
Total Objects: 2 Total Tread Plate Area: 20.83 sq ft .125 AL Tread Plate Weight: 40 lbs .125 Steel Tread Plate Weight: 128.33 lbs
How to do is to have the text appear on multiple lines, instead of all across one line. Is there a way to mimic the enter key to enter the next line of text, just like when you use the text function in AutoCAD, instead of using multiple text commands and having to position each one using code.
(defun c:tread (/ cnt tot ss p sqft alwt stwt) (vl-load-com) (setq cnt 0 tot 0
I have some general knowledge in lisp coding. But I can't seem to figure this one out (even to get started). What I want to do is make a lisp that:
- selects a line
then
- select any amount of text (any type)
then
- moves all the text to that selected line without rotating the text
if a line is perfectly horizontal then move the text of the y axis.
if the line is vertical then move the text of the x axis.
or there can be a prompt asking the user to chose the angle or axis in which the text will move (say if they want to move the text to a slanted line, you can choose to move the text on an angle, while keeping the same format and not rotating the text, or you can ask the user if they want to move it only vertically or horizontally)
I would really like the code to integrate into my autocad.
I have the following code which isnt quite working, it reads a text file which has a list of Names of images and their bottom left coordinates i.e. name x y etc. I want it to check for a name equal to that input then in this case alert the user it is found, eventually I want it to load the tile but for the moment where am I going wrong, also the lisp wont close the file and I dont know why.
(defun c:imi () (setq IM (getstring " Input name of 2010 tile")) (while (not (= "" IM)) (setq TILE (strcat "BM" IM)) [Code] ......
I am a beginner at LISP and this is a bit out of my league... and I'm trying to create a lisp where I can draw a polyline between 2 points that also places text with the actual distance offset above the line.
I did find this post and I'm not quite catching on.. [URL] ......
Would like to be able to select mtext explode it get x y coords of last line of text then turn it back to mtext and then launch mtext at a @0,-0.5 justification TL width 5 and display the ribbon.
All seems to work except the (command ...)
Below is my attempt.
(prompt "Select Note") (setq ss (ssget)) (command "explode" ss) (setq ss (ssget "l")) ;get last line of text
(setq ent (entget (ssname ss 0)) ent1 (cdr (assoc 10 ent))) ;get x y coords (command "undo" "1") ;set exploded mtext back to mtext (setvar "lastpoint" ent1)
I am trying to get a default value (from global variable) put as the default for getstring command. Problem is I want it as if I had typed it into the getstring command so I can modify it if required. It is for entering filenames which only change slightly ie 1129E09LS1 ...LS2 ...XS1 etc.
Current (setq BlkName (getstring " Enter Civil Cad File to Import: ")) For defaults that I don't want to change I usually use this format: (or BlkName (setq BlkName (getstring " Enter Civil Cad File to Import: ")))
I have the following Lisp command that changes a selected layer to a different layer. I have tried modifying it change known layer names to different known layer names. i.e run routine and it changes layer "2" to "3" then changes layer "dim" to "dims" ect then stops.
I need to get the layout list in reverse order. How to do this? My plotter outputs prints face up and I wind up with a stack of drawings in reverse order - If I can cycle through the tabs in reverse order they will wind up in the correct order in the print room!
I have been working on an AutoLISP routine which is intended to:
1) collect input from the user via a DCl dialog box
a) Create a List of the non-null "GROUP_CODE..." variable values collected from the dialog's settings
b) Create a List of the "ESN***#_Part" variable values collected from the dialog's settings (does the List elements' order need to be reversed after collecting them?)
2) Prompt the user to select an insertion point
3) Insert a Block named "ESN-CONTROL-WIRED" which has multiple attributes
a) Apply the first List element collected at step 1.a above to the attribute tag "INPUT_ADD" in the block
b) Apply the first List element collected at step 1.b above to the Attribute Tag "PART_NUMBER" in the block
4) Insert a second instance of the Block named "ESN-CONTROL-WIRED" below the first instance
a) Apply the second List element collected at step 1.a above to the attribute tag "INPUT_ADD" in the block
b) Apply the second List element collected at step 1.b above to the Attribute Tag "PART_NUMBER" in the block etc. .... keep inserting the block "ESN-CONTROL-WIRED" below the previous on until all the input from the dialog has been displayed in the attributes.
Notes:
The Dialog's pop-up lists are populated from external .TXT files which reside on our network (or alternate local C: drive folder if no network drive is found)
Inside the file "ESN_SENSORS_NUMBER.LSP", it is the function "ESN_APPLY_TAG" which I am struggling with how to write...
find inside the .ZIP file:
- (2) example screenshot .BMPs showing dialog box settings and what the resulting output in AutoCAD should look like
- (1) ESN_SENSORS_NUMBER.LSP
- (1) ESN_SENSORS_NUMBER.DCL
- (1) ESN_SENSORS_NUMBER.DWG with a sample output - and the definition of the block ESN-CONTROL-WIRED
- (1) ESN-OCC.txt which populates the PopUp List Boxes
- (1) ESN-DAYLT.txt which populates the PopUp List Boxes
- (1) ESN-IR.txt which populates the PopUp List Boxes
Normally when applying the matchprop command in CAD, one has to first pick the template element, and then select the elements which should have this template element's properties copied to/matched.
is it possible (via lisp perhaps?) to reverse this order, so that i can select a bunch of elements (e.g. through the quickselect icon) and THEN apply a matchpropertieslisp command, then select a single template element which the initially selected elements should mimic?
Any routine that will allow to draw a polyline through existing blocks, in the order the blocks should be numbered? Therefore when the sequence has been specified by the polyline then user to define the number system required, and the blocks are automatically numbered in the sequence of the polyine start to finish.
Will Adobe consider restoring alphabetic filename sorting to PSE11/PrE11 Organizer? This is a fundamental expectation of any file management program and was present in all of my previous versions (2,3,4,5,6,7,8,9,10). Alpjhabetic sorting is critical when files are re-named or re-created and the name sequence no longer follows the date sequence.
I will compliment Adobe for promptly refunding me purchase, but after using PSE/PrE for 9 years, I would really like to be able to continue with their upgrades.
I am trying to draw a line between two lines and I put together the following. It works great if the start/end points are perpendicular to each other. How do I solve if line one start point is in a positive direction and line two is in a negative direction?
(defun c:test () (setq L1 (car (entsel " Select the first line: ")) L2 (car (entsel " Select the second line: ")) )
I am having a problem with starts and ends of lines. I have draw two lines, end of first is start of second. The problem is because, (cdr (assoc 11 (entget line1))) and (cdr (assoc 10 (entget line2))), somehow, are not the same,
I need to place a circle, of a user-defined radius, as a marker at the endpoints of all lines in a drawing. how to accomplish this using lisp? It doesn't matter if they overlap; I can use OVERKILL to delete those objects.