AutoCAD Visual LISP / AutoLISP :: Finding And Replacing Very Special Characters
May 15, 2013
Is there a way to find and/or replace "very" special characters like [carriage return], [backspace] or even [tab mark], considering that the first thing that comes to mind when saying special characters is the standard and extended ASCII only.
I'm trying to write a simple Custom Command that sets any layer that matches "$-*" to a specific color. But as soon as AutoCAD sees the $, it thinks I'm trying to do a DIESEL expression. Supposedly, the quote marks specify that the enclosed characters should be treated as plain text, but that doesn't happen.Here's what I've got:
^C^C-LAYER;C;252;"$-*";;
And this is what I get:
Command: -LAYERCurrent layer: "$-HATCH-00-002-PW-BOAT"Enter an option [?/Make/Set/New/Rename/ON/OFF/Color/Ltype/LWeight/MATerial/Plot/Freeze/Thaw/LOck/Unlock/stAte/Description/rEconcile]: CNew color [Truecolor/COlorbook] : 252Enter name list of layer(s) for color 252 <$-HATCH-00-002-PW-BOAT>: "No matching layer names found.Enter an option [?/Make/Set/New/Rename/ON/OFF/Color/Ltype/LWeight/MATerial/Plot/Freeze/Thaw/LOck/Unlock/stAte/Description/rEconcile]: It stops, hanging at the incompleted -LAYER command prompt.
i have line in the drawing that exists on layer A-Wall it has different lineweight 0.05 from true wall. Now usually my routine : i select this line and then select similar to convert it to layer glazing.
i need lisp that by one command convert the objects on layer A-wall with layer 0.05 only to glazing.
(if (ssget "_X" '((0 . "ACAD_TABLE")(1 . "PIPE LIST")))(progn (vlax-for a (setq ss (vla-get-ActiveSelectionSet (vla-get-ActiveDocument (vlax-get-acad-object)))) (repeat (setq r (vla-get-rows a))(setq r (1- r) c -1)(repeat (vla-get-columns a) (if (eq "*PL*" (vlax-invoke a 'GetText r (setq c (1+ c)))) (vlax-invoke a 'SetText r c "THREAD ONE END"))))) (vla-delete ss)));progn);if
Basically, it replaces this text inside a table:
1 1/2" NPTM - A53 - 3000LB - A-53 - 3000 LB
with:
thread both ends.
But I'm limited to the size of pipe, it's material and its pressure rating. I can't change how the text in the field is populated. It would be nice if, it did a search for NPTM, and when that string exists in the string, change it to "thread both ends".
Essentially right now, I have 46 lines (and growing) of different scenarios. I just want the NPTM to trigger the string change.
I have some legacy custom .DCL files that we want to convert the user interfaces (text boxes, labels, etc) to Chinese characters. Is that even possible in .DCL?
I have gotten our NET and VBA apps converted but not having much luck with the DCL files.
On a Chinese computer with Windows XP, the layout name via ActiveX is displayed correctly "A3 -布局-02" on the variable laynam.
But under Windows 7 64 Bit I get this "A3 -??-02". So all ActiveX objects with AutoLisp commands do not transfer the Chinese Unicode characters, also on a system in china.
But the pure lisp command (layoutlist) for example returns always the correct characters ("A3 -布局-02")
Do I need any Chinese dll’s for ActiveX dependent language? On my test PC I installed the file autocad_2013_traditional_chinese_language_pack_win_64bit in the hope I get shared files for ActiveX but this did not bring success.
I searched the groups and the closest discussion I could find was here but there didn't seem to be a clear cut solution. [URL]. I have a jpg file that I needed to apply some transparency to and saved it as a png file. I now want to delete the jpg file from the folder but it's being referenced in several drawings, and I don't know which ones. Is there a way to reverse the function of Reference Manager (perhaps with a different app), ie find all the drawing files that reference my jpg file?
Intel i7 3.33Ghz, 16Gb RAM Nvidia Quadro 2000D C3D 2012 SP4, holding off on C3D 2014 Win 7-64
as you know, you can write chars on text screen easily: (write-line (strcat "\U+" "2122"))
but if you want to write chars to a text file, this command does not work: (write-line (strcat "\U+" "2122") TxtFileVar)
Here is a part of my code to test: (defun C:HexGen ( / d f S w x y z h c)(setq d '("0" "1" "2" "3" "4" "5" "6" "7" "8" "9" "A" "B" "C" "D" "E" "F") f (open "c:\0000-FFFF.txt" "w"))(foreach w d (foreach x d (foreach y d (progn (setq S "") (foreach z d (progn (setq h (strcat w x y z)) (setq c (strcat "\U+" h));;;<===character (setq S (strcat S " " (strcat h " = " c ))) ) ) (write-line S f) ) ) )) (close f)(startapp "notepad" "c:\0000-FFFF.txt"))
I want to create a table with all characters inside a font.I used "%%" to change a number to it's character.but "%%" limited to 999 and for numbers bigger than 999 it doesn't work.
also, CHR command limited to 255 and for numbers bigger than 255 it change to (number-255). so I used "%%" to create this table:[Please change default font in your AutoCAD to ARIAL]
(defun layun (target_obj / original_layer original_layer_info target_obj_atts new_layer )(setqoriginal_layer (cdr (assoc 8 (entget target_obj)))original_layer_info (tblsearch "layer" original_layer)target_obj_atts (entget target_obj));setq(if (or(wcmatch original_layer "*-P123"); REMOVES 4 CHARACTERS(wcmatch original_layer "*-P123456"); REMOVES 7 CHARACTERS(wcmatch original_layer "*-P123456789"); REMOVES 10 CHARACTERS );or(progn(setq new_layer (substr original_layer 1 (- (strlen original_layer) ??))) ; NEED TO ASSIGN VARIABLE TO MATCH THE NUMBER OF CHARACTERS TO REMOVE(if (not (tblsearch "layer" new_layer))(progn(entmake ;;;begin to make new layer(list'(0 . "LAYER")'(100 . "AcDbSymbolTableRecord")'(100 . "AcDbLayerTableRecord")(cons 2 new_layer) ;;; layer name(assoc 6 original_layer_info) ;;;re-use original linetype'(70 . 0) ;;;flags - use default flags(assoc 62 original_layer_info) ;;;re-use original color);list);entmake);progn);if(entmod (subst (cons 8 new_layer) (assoc 8 target_obj_atts) target_obj_atts)));progn);if);defun
assign a character where ? is shown so that it matches with the number of characters to remove based on the 3 lines above (see wcmatch lines). At present, whatever number I replace that ?? with, it removes that number of characters from the layer that I selected (if it meets that WCMATCH criteria). Another option which may be more difficult is to be able to have the routine look at the object layer and if it contains -N- or -D- or -NEW- or -DEMO- then to remove all the characters that follow these layer modifiers. This way I can cleanly add another project modifier behind these modifers.
I have been searching all over and have not found a method for limiting the number of digits/characters a user can enter for a getstring or getint prompt.
As everybody know copy/paste excel file into an inventor drawing is sometimes difficult. As you can see in the printscreen a special character is not converted. I supposed it's because this special character is not in the AIGDT or is in the extended character set wich is not considered in Inventor?
Is there a lisp that will allow me to do a continuous dimension, but will alternate the dimension position from low, high, low and high? If there is no lisp already created, how to create one?
See Continuous dimension attachment for example.
I work at a glass and glazing company and this is how we dimension mullion width and DLO. See typical window dimensioning attachment for window elevation with dimensions.
I have a list ("temp.dwg" "temp2.dwg") and would like to add the string "insert text here" into each item in the list resulting in ("insert text heretemp.dwg" "insert textheretemp2.dwg"). how would i go about doing that using LISP?
Is there a way to programatically set a visual style before a drawing actually opens?
We have some huge models and people seem to forget to change their visual styles back to 2D wireframe before saving and exiting drawings. Some models will crash on some workstations when trying to open in a rendered mode.
I found a lisp with a function that looked to set viewport visual styles. But it does not seem to be supported anymore. --> (vla-put-VisualStyle vport 1)
I'm trying to write a lisp routine that, when I invoke the mleader command, osmode is set to "nearest" & orthomode is set off. I then would like the original settings to be returned.
Lisp that switches back on Selection Preview i.e. thickens and highlights lines when you hover over them?I don't know why, but they are always unticking the boxes.
I've exported the ePub file from InDesign CC and found some special characters are looks as box i.e., as junk. But while unzip the ePub and open the particular XHTML in internet explore, it displays fine.
I've been wanting to upgrade to CS6 but have one issue that is preventing me from using it exclusively during testing that did not occur in CS5.
When typing special characters the formatting jumps all over the place and the speical characters end up at the end of text and not where I typed them.
It seems that I cannot enter a special character into the text of a title with Alt-0xxx, even though this works with just about all other Windows applications. Is this a feature or a bug? Or is there a way to do this that I'm unaware of?
For the moment I'm entering the special characters into a text editor, then copying and pasting them into the title, which works, but is awkward. I don't understand why VideoStudio doesn't let me enter the characters directly.
The characters in question are things like typographic quotes, some accented characters, bugs like copyright and registered trademark, and other things that are not unusual to need to use in a title.
I'm experiencing a very bizarre problem in CS with a font special character. I used Extensis Suitcase to examine all the font characters for a particular font that I'm using on a project. The character mapping shows the key combination for the character I want is (on a Mac) Option/Alt + Z.
This works in every other application on my computer, including my email application, but for some reason, within CS it brings up the Omega character. Any idea why this happens and how I change it? I even tried to type the character in Word and cut and paste it into Photoshop and it changes! What gives?