Hint...
(setq ss1 (ssget))
(setq pt1 (getpoint "Pick source point 1: "))
(setq pt2 (getpoint "Pick source point 2: "))
(setq pt3 (getpoint "Pick destination point 1: "))
(setq pt4 (getpoint "Pick destination point 2: "))
(command "align" ...

Registered forum members do not see this ad.
New And Improved Align Command
I was wondering if anyone has a lisp that could improve the align tool that they would like to share. Many I have talked to agree that it just seems like a lot of steps.
Not exactly sure how to fix it, because the steps are needed, the only thing I can think of is a lisp that allows you to select the two points on the object you want to align first and then select the two points on the angle line you want to align to. The first point selected on the object is where it will match up with the first point selected on the angle line you want to align the object with.
In essence it is identical to the original align command, you just don't have to go back and forth between object you want to align and the angle line you want to align the block to.
Thank You All In Advance




Hint...
(setq ss1 (ssget))
(setq pt1 (getpoint "Pick source point 1: "))
(setq pt2 (getpoint "Pick source point 2: "))
(setq pt3 (getpoint "Pick destination point 1: "))
(setq pt4 (getpoint "Pick destination point 2: "))
(command "align" ...
John,
You have many requests, so surely it would be beneficial for you to learn LISP? There are so many resources available, and plenty of advice on here if you get stuck.
But then, on second thoughts, there's no reason for you to learn it when us mugs (speaking of myself of course) on here will write the program for you.
Lee Mac Programming
With Mathematics there is the possibility of perfect rigour, so why settle for less?
Just another Swamper

Thank you for the hint, been looking for a while for "align" lisps to modify but most of them seem to be for aligning text, which already exists in autocad.
If you know of any links to align lisps that I can take a look at, this may help.
starting attempt
starting attempt explainedCode:(defun c:aligntest (/ ss1 pt1 pnt1 pt2 pnt2 pt3 pnt3 pt4 pnt4) (setq ss1 (ssget)) (setq pt1 (getpoint "Pick source point 1: ")) (setq pt2 (getpoint "Pick source point 2: ")) (setq pt3 (getpoint "Pick destination point 1: ")) (setq pt4 (getpoint "Pick destination point 2: ")) (command "align")
Lee Mac a.k.a. mug(defun c:aligntest (/ ss1 pt1 pnt1 pt2 pnt2 pt3 pnt3 pt4 pnt4)
defun is obviously what starts the command, from what I understand (/ ) contains a step process layout of how the lisp works.
ss1 -requests object to select
pt1 -asks for point
pnt1 -click point
etc.
(setq ss1 (ssget)) --- requests object to select
(setq pt1 (getpoint "Pick source point 1: ")) -request 1st point of object
(setq pt2 (getpoint "Pick source point 2: ")) -request 2nd point of object
(setq pt3 (getpoint "Pick destination point 1: ")) -request 1st point of angle
(setq pt4 (getpoint "Pick destination point 2: ")) -request 2nd pnt of angle
(command "align")
-this one kind of throws me for a loop, I get that when you want to activate a command you use (command "name of command" not exactly what you put after it) The thing that confuses me on this is that we are editing the command, so if you call up the align command, how will it know our new point selection structure?
Please be patient, am I the only one who wants an improved align command? My posts get quite a few of views, so I am not the only one looking for the lisps I request. I am more than willing to take the brunt abuse, but hopefully others find my questions and the responses to them helpful. I do try to learn from them despite what people think and
I do appreciate all the help I have been given.




You don't need pnt1-pnt4... setq sets the variable pt1 to the coordinates you pick in the (getpoint function
the (/ ...) after the defun declares the variables local
Pass the selection set and points [the variables pt1-pt4] to the align command in the order you would if you were doing it from the command line, all within the open and close parenthesis. Another hint, "" equals Enter.
Last edited by lpseifert; 13th Feb 2010 at 12:20 am.

Here is another attempt....
I understand the "command" concept, where the " " are placed around the steps of the command, but the align tool is a little different. It asks for points the minimum fours points in order to align the object. Gets a little confusing because we are trying to modify the original command so are you entering the points based on the original command or the points based on your new creation?
Like I said I have been looking for align lisp examples but I haven't been able to find any that don't deal with text, and or use the "command" line in it.
produces error = error: malformed list on inputCode:(defun c:aligntest (/ ss1 pt1 pt2 pt3 pt4) (setq ss1 (ssget)) (setq pt1 (getpoint "Pick source point 1: ")) (setq pt2 (getpoint "Pick source point 2: ")) (setq pt3 (getpoint "Pick destination point 1: ")) (setq pt4 (getpoint "Pick destination point 2: ")) (command "align" "pt1" "pt2" "pt3" "pt4" "N" "")
Again I thank you for your patience and for coming back to help me out.


Malformed list on input usually means missing right paren ")" .
Steve




Enter the steps in the (command ...) like you'd do from the command line; you forgot feed the selection set to the command; the variables should not be enclosed in quotes; pay attention to the order you feed the point variables to the command; don't forget to close the defun (that's where the malformed list error came from)
This is all pretty basic programming in Autolisp... you may want to consider visiting these sites and running through some of the lessons/tutorials
http://afralisp.net/
http://ronleigh.info/autolisp/index.htm
Last edited by lpseifert; 17th Feb 2010 at 10:23 am.

Here is another attempt, but this time I get a syntax error?
Below is a breakdown of the align command steps, maybe you can help me by pointing out what I am doing wrong.Code:(defun c:aligntest (/ ss1 pt1 pt2 pt3 pt4)) (setq ss1 (ssget)) (setq pt1 (getpoint "Pick source point 1: ")) (setq pt2 (getpoint "Pick source point 2: ")) (setq pt3 (getpoint "Pick destination point 1: ")) (setq pt4 (getpoint "Pick destination point 2: ")) (command "align" ss1 "" pt1 pt3 pt2 pt4 "" "N" "")
Also thank you for the site recommendations.Code:(command "align" ss1 "" pt1 pt3 pt2 pt4 "" "N" "") align = command start select objects = ss1 enter after select object = "" select first source point = pt1 select first source point destination = pt3 select second source point = pt2 select second source point destination = pt4 enter after done selecting points = "" do you want to scale object = "N" for no enter to finish command = ""
I have been looking into some websites for a while now, I know of afralisp which is okay, I have also been trying to learn from this site
http://www.jefferypsanders.com
The site you recommended http://ronleigh.info/autolisp/index.htm I had not seen before, this one is now my favorite. This is a great site, it is setup exactly what I am looking for to learn. I have been trying to learn from the lisps people have been creating for me but couldn't understand a great deal. This site helps a lot because I can look up code specifically, due to the list breakdowns of the different commands.
I am not saying I am going to be able to write complicated commands tomorrow, I am still having trouble with my align command above, but once we finish this one, I am going to look into my collection of lisps and now be able to analyze them a lot better with that website.




Registered forum members do not see this ad.
Move the closing parenthesis at the end of line 1 to the very end of the code; get rid of the "" after "N" in the command line,(if done at the command line, N ends the command, no need for an enter there)
also, try this and see what happens
Code:(setq pt3 (getpoint pt1 "Pick destination point 1: ")) (setq pt4 (getpoint pt2 "Pick destination point 2: "))
Bookmarks