Visual LISP, AutoLISP and General Customization

Visual LISP, AutoLISP and General Customization

Reply
Active Member
amr4alex
Posts: 8
Registered: ‎12-04-2012
Message 1 of 7 (620 Views)
Accepted Solution

Invalid point error

620 Views, 6 Replies
12-04-2012 02:15 AM

Hi

need help in this please,

When I use the line

(command "_break" "_f" (car (nentsel)) "0,0" "@") 

I get "invalid point" error

And I have I question I when I use "command" to excute autocad command that draw a "pline"

autocad wouldn't understand coordinates unless I put befor it "_non"

Example

(command "_pline" "_non" coo "") 

Assume that "coo" is a pints list in the form

((0,0)(1,1)(2,2))

 

Thanks for help

*Expert Elite*
Kent1Cooper
Posts: 5,394
Registered: ‎09-13-2004
Message 2 of 7 (606 Views)

Re: Invalid point error

12-04-2012 05:28 AM in reply to: amr4alex

amr4alex wrote:

....When I use the line

(command "_break" "_f" (car (nentsel)) "0,0" "@") 

I get "invalid point" error

And I have I question I when I use "command" to excute autocad command that draw a "pline"

autocad wouldn't understand coordinates unless I put befor it "_non"

Example

(command "_pline" "_non" coo "") 

Assume that "coo" is a pints list in the form

((0,0)(1,1)(2,2))

....


When using the (command) function, you must provide answers to the command's prompts just as you would if using the same command manually at the Command: line, of the correct type of information for each prompt, and in the correct order.  When using Break that way, it wants the object before the First option -- if you give it the F first, it goes into Fence selection mode, and the entity name you give it next is not valid as a Fence point.  And when using Pline, it wants a point, or one point at a time, not a list of points all at once.

 

For the Break, try:

(command "_break" (car (nentsel)) "_f" "0,0" "@")

though I wonder whether you will be able to break a nested entity [it may vary with the host entity type].

 

And for the Polyline, something like this should work [untested]:

(command "_.pline"); start command

(foreach pt coo (command pt)); feed points in list out to command one at a time

(command ""); end Polyline

 

The "_non" is just an object-snap mode, turning it off for the next specified point.  Commands will recognize a point without it, but if you have running Object Snap modes on, it may snap to a location different from the one given.

Kent Cooper
Active Member
amr4alex
Posts: 8
Registered: ‎12-04-2012
Message 3 of 7 (601 Views)

Re: Invalid point error

12-04-2012 05:58 AM in reply to: amr4alex
Thanks kent for pline explanation ,

I'm only want to break a single line
and I tray it with lisp file and also using autocad command console
and i'm using the same command that you write
And still not working
*Expert Elite*
hmsilva
Posts: 2,778
Registered: ‎12-17-2004
Message 4 of 7 (595 Views)

Re: Invalid point error

12-04-2012 06:33 AM in reply to: amr4alex

Try

 

(command "_.break" pause "_f" pause "@" )

 

Henrique

*Expert Elite*
Kent1Cooper
Posts: 5,394
Registered: ‎09-13-2004
Message 5 of 7 (585 Views)

Re: Invalid point error

12-04-2012 07:17 AM in reply to: amr4alex

amr4alex wrote:
....I'm only want to break a single line
and I tray it with lisp file and also using autocad command console
and i'm using the same command that you write
And still not working

I think I led you astray somewhat....  Since my earlier Reply, I remembered something I discovered some time ago, but that had slipped my mind: if you give Break an entity name [which is what your (car (nentsel)) will return], rather than picking something, it assumes the "First" option, since the entity name alone doesn't give it a possible starting point for the Break.  So it doesn't offer that option, but asks immediately for the first point.  Try it, by drawing something Breakable, calling up Break manually, and typing L for Last when it asks you to select an object.

 

If you don't use hmsilva's suggestion with just a pause for User selection, but stay with something that provides an entity name, then you should not specify the "First" option.  If you want the break point to be at 0,0 as in your original, and are not Breaking a nested entity, you could try:

 

(command "_.break" (car (entsel)) "0,0" "@")

 

But hmsilva's approach, with the pause and the specified First option, is just as good.  However, if [for example] you have an entity name saved into a variable and want to Break that entity at 0,0:

 

(command "_.break" YourEntityName "0,0" "@")

 

Another reason you might not want to use the simpler pause-based approach is if you want to give the User instructions in a prompt that is more specific than Break's plain "Select object:" prompt:

 

(command "_.break" (car (entsel "\nSelect Line to be broken at 0,0: ")) "0,0" "@")

Kent Cooper
Active Member
amr4alex
Posts: 8
Registered: ‎12-04-2012
Message 6 of 7 (578 Views)

Re: Invalid point error

12-04-2012 07:54 AM in reply to: amr4alex
Thanks Henrique worked like this

(command "_break" pause "_f" "0,0" "@")
so you made notice that the problem in selection method so I tried this also worked


(command "_break" (nentsel) "_f" "0,0" "@")

But I don't know the difference ,
Thanks to all.
*Expert Elite*
Kent1Cooper
Posts: 5,394
Registered: ‎09-13-2004
Message 7 of 7 (558 Views)

Re: Invalid point error

12-04-2012 09:32 AM in reply to: amr4alex

amr4alex wrote:
....worked like this
(command "_break" pause "_f" "0,0" "@")
....this also worked
(command "_break" (nentsel) "_f" "0,0" "@")
But I don't know the difference ,
....

I would use (entsel) rather than (nentsel), because (nentsel) is for nested entities, such as sub-entities inside Block insertions or Xrefs, and you won't be permitted to Break such a thing.  But (nentsel) will recognize a top-level entity if the selected object is not nested, so in that case, at least it will still work, even though it's not the most appropriate function.

 

Apart from that, there is no real difference between those two.  The pause in the first one will return the result of the User's pick, answering the Break command's "Select object:" prompt, and it will "see" both the selected object and the location at which it was picked.  The (entsel) [or (nentsel)] in the second one will return a list, containing the entity name of the selected object and the location at which it was picked -- the same things seen by the User's selection at the pause in the first one.

 

Since the entity name is the first item in the list returned by (entsel), and the location is the second item, you could also do this:

(command "_break" (car (entsel)) "0,0" "@"); entity name only, First option is automatic; opportunity to specify prompt that pause does not give you;

or even this:

(command "_break" (cadr (entsel)) "f" "0,0" "@"); selection point only, but there's no point in doing it that way instead of as above, or with pause.

Kent Cooper
Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.