Jump to content

New And Improved Align Command


Recommended Posts

Posted

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

Posted

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" ...

Posted

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.

Posted

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

 

(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")

 

starting attempt explained

 

(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?

 

Lee Mac a.k.a. mug

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.

Posted

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.

Posted

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.

 

(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" "")

 

produces error = error: malformed list on input

 

Again I thank you for your patience and for coming back to help me out.

Posted

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

 

Steve

Posted

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

Posted

Here is another attempt, but this time I get a syntax error?

 

(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" "")

 

Below is a breakdown of the align command steps, maybe you can help me by pointing out what I am doing wrong.

 

(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 = ""

 

Also thank you for the site recommendations.

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.

Posted

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

(setq pt3 (getpoint pt1 "Pick destination point 1: "))
(setq pt4 (getpoint pt2 "Pick destination point 2: "))

Posted

Success!

Nice, it works great, I have already been using it a great deal.

 

I also applied the tweak you supplied above, that is pretty cool, by adding the pt1 and pt2 the align line guides line up to the appropriate points, just like in the stock align command, very nice.

 

Thank you very much for sticking it out with me, I appreciate all your help.

Now that I have some great resources, I will now continue on my quest to learn about lisp. I will eventually try to work on my radius tick lisp request and see if I can solve it, but I don't think I am ready for that just yet.

 

Thanks Again

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...