Jump to content

Recommended Posts

Posted

Try to accomplish a simple task by lisp:

 

 

1. Draw a line from A to B

2. Draw a small circle at A

3. Use command Arraypath

4. Select the circle

5. Select the line as curve

6. Method -> Divide

7. Item -> 5 (could be any number)

 

 

I do this in autocad and it works all the time no matter how to draw the line and whether the circle is placed at A or B

 

 

When I use the following lisp, it only works the line is drawn from left to right, or from top to bottom, and the circle is placed at A:

 

 

(DEFUN C:InsDistributedBar ()

(command ".LINE" pause pause "")

(setq lastline (entlast))

(command ".circle" pause pause "")

(setq lastbar (entlast))

(command ".arraypath" lastbar "" lastline 5 "D" "")

)

 

 

When I replace the arraypath to mimic the direct input for Command Arraypath by the following line:

(command ".arraypath" lastbar "" lastline "M" "D" "I" 5 "")

 

 

The code doesn't work at all. The execution echo is:

 

 

Command: .arraypath

Select objects: 1 found

 

Select objects:

Type = Path Associative = Yes

 

Select path curve:

Enter number of items along path or [Orientation/Expression] : M Requires an integer between 1 an 32767, or option keyword.

Enter number of items along path or [Orientation/Expression] : D Requires an integer between 1 an 32767, or option keyword.

Enter number of items along path or [Orientation/Expression] : I Requires an integer between 1 an 32767, or option keyword.

Enter number of items along path or [Orientation/Expression] : 5

Specify the distance between items along path or [Divide/Total/Expression]:

Select grip to edit array or [ASsociative/Method/Base point/Tangent direction/Items/Rows/Levels/Align items/Z direction/eXit]: nil

 

 

I don't know that much about lisp. I don't know what is wrong.

 

 

Please help.

 

 

Thanks.

 

 

Xiaoping

Posted

Try this

 

(DEFUN C:InsDistributedBar ()
 (command ".LINE" pause pause "")
 (setq lastline (entlast))
 (command ".circle" pause pause)
 (setq lastbar (entlast))
 (command "arraypath" lastbar "" lastline 5 "D" "M" "D" "")
 (princ)
)

 

 

(command "arraypath" lastbar "" lastline [b][color="red"]5 "D" "M" "D" ""[/color][/b])

Does the same thing which you were trying for but with little variation...

 

If you can give Divide option in your code itself then why are you trying for Method->Divide

Posted

The reason I was trying

 

 

(command ".arraypath" lastbar "" lastline "M" "D" "I" 5 "")

 

 

is to mimic the way you would direct use Arraypath in autocad.

 

 

I tried your code

 

 

(command "arraypath" lastbar "" lastline 5 "D" "M" "D" "")

 

 

It still doens't work. Tried to draw the line in different ways and sometimes the 5 circles could be placed in the opposit direction.

 

 

Thanks.

 

 

Xiaoping

Posted

Ohh Sorry didnt check that

 

Try this now :

(defun c:test (/ a b l c)
 (if
   (setq a (getpoint "\nSpecify start point : ")
  b (getpoint a "\nSpecify end point : ")
   )
    (progn
      (command ".line" a b "")
      (setq l (entlast))
      (command ".circle" a pause)
      (setq c (entlast))
      (command ".arraypath" c "" l "O" a b "E" 5 "D" "X")
    )
 )
 (princ)
)

Posted

Trie your code, works perfect!

 

 

Thanks a lot!

 

 

Although I don't understand where the "O" option is from. Where can I get the document as how to use the command in lisp? (syntax, arguments, ...).

 

 

Xiaoping

Posted
Trie your code, works perfect!

 

Thanks a lot!

 

Xiaoping

 

Glad to here that :)

 

 

Although I don't understand where the "O" option is from.

 

"O" stands for Orientation.... You can see that in commandline

 

Where can I get the document as how to use the command in lisp? (syntax, arguments, ...).

Xiaoping

 

There are websites available where you learn lisp...

e.g.

http://www.afralisp.net/index.php

http://lee-mac.com/index.html

Posted

I checked autocad 2015 command line and don't see Orientation option. I also checked the arraypath document and don't see this option either.

 

 

http://knowledge.autodesk.com/support/autocad/learn-explore/caas/CloudHelp/cloudhelp/2015/ENU/AutoCAD-Core/files/GUID-D36C46CD-4E17-4A16-A387-C0B158EA5A9E-htm.html

 

 

Would you please show me where you get this option?

 

 

Thanks.

 

 

Xiaoping

Posted

This example is taken from your 1st post... See red highlight

Command: .arraypath
Select objects: 1 found

Select objects:
Type = Path Associative = Yes

Select path curve:
Enter number of items along path or [[color="red"]Orientation[/color]/Expression] <[color="red"]Orientation[/color]>: M Requires an integer between 1 an 32767, or option keyword.

Posted

That one was the echo from the arraypath executed from the code. If you use arraypath command directly in autocad command line, you don't get that Orientation option.

 

 

It seems that when you use the command directly, the options and arguments provided/required are different from the one executed within lisp (command ".." ...). It doesn't make sense. Where are these documented?

Posted

You are absolutely right. I have noticed that. M also 1st time came across such things. Normally command executes in same manner from Manual and automatic operation in autocad. I don't think there will any documentary on this. I would be interested if it is available. In such scenario experience n practice comes into picture.

  • 1 year later...
Posted
That one was the echo from the arraypath executed from the code. If you use arraypath command directly in autocad command line, you don't get that Orientation option.

 

 

It seems that when you use the command directly, the options and arguments provided/required are different from the one executed within lisp (command ".." ...). It doesn't make sense. Where are these documented?

 

 

If I execute ARRAYPATH manually (command line), then it works how I want it to, but if I try to make it a script or macro (I'm using LT), the options are totally different and it doesn't work. What is the logic behind this and how do I work around it?

There is a need in our office for us to do an array along a centreline on a pretty regular basis, so it would be better to have a button to press rather than having to manually type all the options in every time.

  • 7 years later...
Posted

Can we use trim command in autolisp. IF I want trim some particular coodinate points means how to do that,Can u pls send me a sample code for trim command

 

Posted (edited)

Just write down what you do now manually, that is the basics of your lisp code. The steps have to be in lisp code format.

 

You can use Logfileon to record the manual steps, logfileoff to turn off logfile, the Log file is stored in your temporary directory path, look at Options, FIle, temporary path for location.

 

 

Edited by BIGAL
  • Like 1
  • Agree 1

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