Friday, January 28, 2011

Notepad2 tips to find and replace newlines

If you want to search in a textfile for newline (aka line break or end-of-line (EOL) character) here are some tips when using Notepad2.

Newline is typically defined with a character set of either LF (Line feed, '\n', 0x0A, 10 in decimal) or CR (Carriage return, '\r', 0x0D, 13 in decimal) individually, or CR followed by LF (CR+LF, '\r\n', 0x0D 0x0A).

This from from the Notepad2 FAQ:

Can I do multiline find and replace?
This is possible when activating the Transform backslashes option in the find and replace dialog boxes. Enter \n to represent the LF character, or \r for the CR. If line ending mode is set to Windows (CR+LF), \r\n has to be used to represent newline sequences.

To perform a replacement operation with multiline text as the replacement, it's easier to copy the text to the clipboard first, and then use ^c as a placeholder for the clipboard contents in the replacement field.

Here is an example where I add extra newlines by searching for \n and replace with \n\n.

Here is the result of it. Note that Transform backslashes must be checked.

Another thing that can be useful is how to handle tab characters.

If you activate Regular expression search in the find and replace dialog boxes, the \t sequence represents a tab character both in the find and in the replace text.

Tuesday, January 25, 2011

Bootstrap Your AutoCAD Deployments

Here is a tip on January/February 2011 issue of AUGIWorld.

R. Robert Bell has done a great work with the “Bootstrap Your AutoCAD Deployments” article and shows an example on how the profiles.lsp can be put to use.

"Bootstrapping AutoCAD from the secondary installer removes a great deal of the complexity in deploying AutoCAD. The addition of a single file to the deployment package can make deploying AutoCAD to users a seamless experience. When the bootstrap is combined with locating the user’s customizations on the network the user no longer suffers as large a productivity hit when he or she uses new hardware. The bootstrap also makes the CAD Manager’s and IT staff’s life much easier because the complexity of dealing with the secondary installer has been mitigated. The bootstrap should make it easier to roll out new versions of AutoCAD in a timely manner because less time needs to be spent configuring a deployment approach.”

Thursday, January 20, 2011

ADDSELECTED command update

If you run into this problem using Add Selected on leaders in AutoCAD 2011 or verticals there is a solution available.

You run the ADDSELECTED command and select an existing leader object to create a new leader.  After picking the first two points, you press "Enter" and AutoCAD begins continuously prompting for the next line of text, forcing you to use Task Manager to kill the AutoCAD process.

For the solution see KB: TS16158933

With the ADDSELECTED command, you can create a new object with the same object type as a selected object. It is also possible extending ADDSELECTED to support custom objects by editing the AcSelCmdMap.xml file.

Tuesday, January 4, 2011

getkword initget and default in AutoCAD’s AutoLISP

Looking in AutoCAD’s AutoLISP Reference there are examples like this:

(initget "Abc Def _Ghi Jkl")
(getkword "\nEnter an option (Abc/Def): ")

(initget 1 "Yes No")
(setq x (getkword "Are you sure? (Yes or No) "))

First off both examples should be updated to follow how command prompts are looking in AutoCAD like in the COPY command:

Specify base point or [Displacement/mOde] <Displacement>:

That means the examples would look like this when using:

(getkword "\nEnter an option [Abc/Def]: ")

(setq x (getkword "Are you sure? [Yes/No]: "))

Now to default. How is it achieved? Default should happen when you press Enter and thus initget 1 cannot be used because bit 0 set to 1 “Prevents the user from responding to the request by entering only ENTER”.

The documentation says on the return values of getkword: “A string representing the keyword entered by the user; otherwise nil, if the user presses ENTER without typing a keyword. The function also returns nil if it was not preceded by a call to initget to establish one or more keywords.”

The trick is then to check for if getkword is nil using (not kw).

So finally here is a sample solution of how get default:

(initget "Yes No")
(setq kw (getkword "Are you sure? [Yes/No] <Yes>: "))
(cond 
  ((or (not kw) (= "Yes" kw)) (alert "YES")) 
  ((= "No" kw) (alert "NO")) 
)

And here is the result and as you can see Yes is the default:

This can also be used with other get*** functions like getdist, getint, getorient, getpoint, getreal and getstring

Some of the latest blog posts

Subscribe to RSS headline updates from:
Powered by FeedBurner

Contact Us | About JTB World | Subscribe to this blog
JTB World's website | Website General Terms of Use | Privacy Policy
^ Top of page

© 2004- JTB World. All rights reserved.