| Author |
Message |
Jimmy D
Guest
|
Posted:
Fri Jan 07, 2005 7:46 pm Post subject:
Offset returns error |
|
|
Hi,
Why does this:
(setq L1 (entsel "\nSelect 1st Line ..."))
(setq L2 (entsel "\nSelect 2nd Line ..."))
(setq OffSetDist (getreal "\nGive Offset Distance..."))
(setq PF1 (cadr L1)
PF2 (cadr L2))
(command ".offset" OffSetDist L2 PF1 L1 PF2 "" )
give this error:
; error: bad argument type: lentityp nil
but when I CtrC/CtrV this:
(command ".offset" OffSetDist L2 PF1 L1 PF2 "" )
to the command line it works OK?
Jim.
|
|
| Back to top |
|
 |
Kent Cooper, AIA
Guest
|
Posted:
Fri Jan 07, 2005 8:20 pm Post subject:
Re: Offset returns error |
|
|
I think you want (car L1) and (car L2), rather than (cadr). As I recall,
(car) gives you the entity, and (cdr) or (cadr) would give you othe point at
which it was selected.
--
Kent Cooper, AIA
"Jimmy D" wrote...
| Quote: | Hi,
Why does this:
(setq L1 (entsel "\nSelect 1st Line ..."))
(setq L2 (entsel "\nSelect 2nd Line ..."))
(setq OffSetDist (getreal "\nGive Offset Distance..."))
(setq PF1 (cadr L1)
PF2 (cadr L2))
(command ".offset" OffSetDist L2 PF1 L1 PF2 "" )
give this error:
; error: bad argument type: lentityp nil
but when I CtrC/CtrV this:
(command ".offset" OffSetDist L2 PF1 L1 PF2 "" )
to the command line it works OK?
Jim. |
|
|
| Back to top |
|
 |
Rogerio_Brazil
Guest
|
Posted:
Fri Jan 07, 2005 8:26 pm Post subject:
Re: Offset returns error |
|
|
Hi, I, tested and ok!!!!
No errors in cad 2k5.
(defun C:ofs ()
(setq L1 (entsel "\nSelect 1st Line ..."))
(setq L2 (entsel "\nSelect 2nd Line ..."))
(setq OffSetDist (getreal "\nGive Offset Distance..."))
(setq PF1 (cadr L1)
PF2 (cadr L2))
(command ".offset" OffSetDist L2 PF1 L1 PF2 "" )
(princ))
:)
Rogerio
|
|
| Back to top |
|
 |
Kent Cooper, AIA
Guest
|
Posted:
Fri Jan 07, 2005 8:27 pm Post subject:
Re: Offset returns error |
|
|
Oops... too quick on the draw. I didn't quite read your (command) line
closely enough. What you want is
(setq L1 (car (entsel "\nSelect 1st Line ...")))
and
(setq L2 (car (entsel "\nSelect 2nd Line ...")))
This is because (entsel) returns the entity as the first item, and the point
you picked it at as the second (I think your PF1 and PF2 are correct). So
to save the entity itself to be fed back for object selection, you have to
put the (car) in front of the (entsel).
--
Kent Cooper, AIA
"Kent Cooper, AIA" wrote...
| Quote: | I think you want (car L1) and (car L2), rather than (cadr). As I recall,
(car) gives you the entity, and (cdr) or (cadr) would give you othe point
at which it was selected.
--
Kent Cooper, AIA
"Jimmy D" wrote...
Hi,
Why does this:
(setq L1 (entsel "\nSelect 1st Line ..."))
(setq L2 (entsel "\nSelect 2nd Line ..."))
(setq OffSetDist (getreal "\nGive Offset Distance..."))
(setq PF1 (cadr L1)
PF2 (cadr L2))
(command ".offset" OffSetDist L2 PF1 L1 PF2 "" )
give this error:
; error: bad argument type: lentityp nil
but when I CtrC/CtrV this:
(command ".offset" OffSetDist L2 PF1 L1 PF2 "" )
to the command line it works OK?
Jim. |
|
|
| Back to top |
|
 |
Jimmy D
Guest
|
Posted:
Fri Jan 07, 2005 8:34 pm Post subject:
Re: Offset returns error |
|
|
Thanx both, but my problem still isn't solved.
(car gives entity name; cdr gives (( 10.0 10.0 0.0)) in dubble brackets and doesn't work). |
|
| Back to top |
|
 |
Kent Cooper, AIA
Guest
|
Posted:
Fri Jan 07, 2005 8:40 pm Post subject:
Re: Offset returns error |
|
|
It occurs to me that since PF1 and PF2 are locations, which would work for
selecting in the Offset command, you might also be able to do
(command ".offset" OffSetDist PF2 PF1 PF1 PF2 "" )
And, I think you could even skip saving the line entities at all -- just
save those two points as points in the first place.
--
Kent Cooper, AIA
"Kent Cooper, AIA" wrote...
.....
| Quote: | "Jimmy D" wrote...
Hi,
Why does this:
(setq L1 (entsel "\nSelect 1st Line ..."))
(setq L2 (entsel "\nSelect 2nd Line ..."))
(setq OffSetDist (getreal "\nGive Offset Distance..."))
(setq PF1 (cadr L1)
PF2 (cadr L2))
(command ".offset" OffSetDist L2 PF1 L1 PF2 "" )
give this error:
; error: bad argument type: lentityp nil
but when I CtrC/CtrV this:
(command ".offset" OffSetDist L2 PF1 L1 PF2 "" )
to the command line it works OK? |
|
|
| Back to top |
|
 |
Jimmy D
Guest
|
Posted:
Fri Jan 07, 2005 8:45 pm Post subject:
Re: Offset returns error |
|
|
I think the problem is with the "ENTER" to close offset command. This is what I get in my text window when using the lisproutine:
....
Specify offset distance or [Through] <Through>: 50.00
Select object to offset or <exit>:
Specify point on side to offset:
Select object to offset or <exit>:
Specify point on side to offset:
Select object to offset or <exit>: ----->error created here
Command: ; error: bad argument type: lentityp nil
This is what I get with CtrC/CtrV the line to the command line (which works OK)
Command: (command ".offset" OffSetDist L2 PF1 L1 PF2 "" )
offset
Specify offset distance or [Through] <50.000>: 50.00
Select object to offset or <exit>:
Specify point on side to offset:
Select object to offset or <exit>:
Specify point on side to offset:
Select object to offset or <exit>: ----> no error here
Command: nil |
|
| Back to top |
|
 |
Kent Cooper, AIA
Guest
|
Posted:
Fri Jan 07, 2005 8:52 pm Post subject:
Re: Offset returns error |
|
|
I think (without digging into help to get the gory details) that (cdr) gives
you the REST OF THE LIST after the first member. Apparently it returns it
in the form of a list with, in the case of what it's starting with from
(entsel), only one member, and that one member has parentheses around it,
but so does the list -- hence the double parentheses.
But apparently (cadr) gives the FIRST MEMBER of the rest of the list after
the first member. It's returning an item, not a list, so it only has the
one set of parentheses.
I tried it out -- where (cdr (entsel)) returns
((10.0 10.0 0.0)),
doing (cadr (entsel)) instead returns
(10.0 10.0 0.0)
Does that fix it?
--
Kent Cooper, AIA
"Jimmy D" wrote...
| Quote: | Thanx both, but my problem still isn't solved.
(car gives entity name; cdr gives (( 10.0 10.0 0.0)) in dubble brackets
and doesn't work). |
|
|
| Back to top |
|
 |
Jimmy D
Guest
|
Posted:
Fri Jan 07, 2005 8:54 pm Post subject:
Re: Offset returns error |
|
|
Hi Kent and Rogerio,
I've tried all your suggestions, but none work :(
I have the weekend to think it over (it's evening
over here and I'm already 1 hour in overtime) so I think
I will give it a rest.
Thanks for your help and have a nice weekend!
Jim |
|
| Back to top |
|
 |
Rogerio_Brazil
Guest
|
Posted:
Fri Jan 07, 2005 9:04 pm Post subject:
Re: Offset returns error |
|
|
See:
OFFSETDIST = VARIABLE
OffSetDist = your variable
Try renaming OffSetDist to OffDist.
(defun C:ofs ()
(setq L1 (entsel "\nSelect 1st Line ..."))
(setq L2 (entsel "\nSelect 2nd Line ..."))
(setq OffDist (getreal "\n Give Offset Distance..."))
(setq PF1 (cadr L1)
PF2 (cadr L2))
(command ".offset" OffDist L2 PF1 L1 PF2 "" )
(princ))
or
(defun C:ofs ()
(setq L1 (entsel "\nSelect 1st Line ..."))
(setq L2 (entsel "\nSelect 2nd Line ..."))
(setq OffDist (getreal "\n Give Offset Distance..."))
(setq PF1 (cadr L1)
PF2 (cadr L2))
(command ".offset" OffDist L1 PF1 "")
(command ".offset" OffDist L2 PF2 "")
(princ))
:)
Rogerio |
|
| Back to top |
|
 |
Kent Cooper, AIA
Guest
|
Posted:
Fri Jan 07, 2005 9:04 pm Post subject:
Re: Offset returns error |
|
|
That's odd. I can't say it would explain the difference you're getting, but
is there any chance the extra spaces have anything to do with it? You have
two spaces after OffSetDist, and two spaces after PF2, and a space after the
final "", none of which I think are needed. I know in macros and scripts
and such, outside (command) functions, every space really matters and means
something, but maybe it ignores extras inside (command) functions. But I
guess it would be pretty unexplainable if it ignored them when the (command)
function is by itself, but didn't ignore them when it's part of a longer
routine.
--
Kent Cooper, AIA
"Jimmy D" wrote...
| Quote: | I think the problem is with the "ENTER" to close offset command. This is
what I get in my text window when using the lisproutine:
...
Specify offset distance or [Through] <Through>: 50.00
Select object to offset or <exit>:
Specify point on side to offset:
Select object to offset or <exit>:
Specify point on side to offset:
Select object to offset or <exit>: ----->error created here
Command: ; error: bad argument type: lentityp nil
This is what I get with CtrC/CtrV the line to the command line (which
works OK)
Command: (command ".offset" OffSetDist L2 PF1 L1 PF2 "" )
offset
Specify offset distance or [Through] <50.000>: 50.00
Select object to offset or <exit>:
Specify point on side to offset:
Select object to offset or <exit>:
Specify point on side to offset:
Select object to offset or <exit>: ----> no error here
Command: nil |
|
|
| Back to top |
|
 |
Rogerio_Brazil
Guest
|
Posted:
Fri Jan 07, 2005 9:19 pm Post subject:
Re: Offset returns error |
|
|
Really strange. In cad 2005 a routine run fine, without modifications.
Have a nice weekend too!
Rogerio :) |
|
| Back to top |
|
 |
Jimmy D
Guest
|
Posted:
Fri Jan 07, 2005 9:23 pm Post subject:
Re: Offset returns error |
|
|
I have tried all your suggestions (car, cdr, cadr, OFFDIST, ...) but nothing works. The problems seems to be with the last "" to close the offset command.
When I try the following at the command line everything works fine:
Command:
OFFSET
Specify offset distance or [Through] <50.000>: 50
Select object to offset or <exit>: !L1
(<Entity name: 40082fa0> (351.228 120.822 0.0))
Specify point on side to offset: !PF2
(461.965 219.989 0.0)
Select object to offset or <exit>: !L2
(<Entity name: 40082fa8> (461.965 219.989 0.0))
Specify point on side to offset: !PF2
(461.965 219.989 0.0)
Select object to offset or <exit>:
Command:
Anyway, I'm realy going home now!
Have a nice weekend! |
|
| Back to top |
|
 |
Joe Burke
Guest
|
Posted:
Fri Jan 07, 2005 9:31 pm Post subject:
Re: Offset returns error |
|
|
Gory details?
Command: (setq lst '(1 2))
(1 2)
Command: (car lst)
1
Command: (cadr lst)
2
Command: (cdr lst)
(2)
Joe Burke
"Kent Cooper, AIA" <kcooper@schwamarchitects.com> wrote in message
news:41deb032_2@newsprd01...
| Quote: | I think (without digging into help to get the gory details) that (cdr) gives you the
REST OF THE LIST after the first member. Apparently it returns it in the form of a
list with, in the case of what it's starting with from (entsel), only one member,
and that one member has parentheses around it, but so does the list -- hence the
double parentheses.
But apparently (cadr) gives the FIRST MEMBER of the rest of the list after the
first member. It's returning an item, not a list, so it only has the one set of
parentheses.
I tried it out -- where (cdr (entsel)) returns
((10.0 10.0 0.0)),
doing (cadr (entsel)) instead returns
(10.0 10.0 0.0)
Does that fix it?
--
Kent Cooper, AIA |
|
|
| Back to top |
|
 |
Jeff Mishler
Guest
|
Posted:
Fri Jan 07, 2005 9:33 pm Post subject:
Re: Offset returns error |
|
|
For what it's worth, I tried the code in the original post in R2002 and it
works just fine........
--
Jeff
check out www.cadvault.com
"Jimmy D" <nospam@address.withheld> wrote in message
news:2218164.1105115050788.JavaMail.jive@jiveforum1.autodesk.com...
| Quote: | I have tried all your suggestions (car, cdr, cadr, OFFDIST, ...) but
nothing works. The problems seems to be with the last "" to close the
offset command.
When I try the following at the command line everything works fine:
Command:
OFFSET
Specify offset distance or [Through] <50.000>: 50
Select object to offset or <exit>: !L1
(<Entity name: 40082fa0> (351.228 120.822 0.0))
Specify point on side to offset: !PF2
(461.965 219.989 0.0)
Select object to offset or <exit>: !L2
(<Entity name: 40082fa8> (461.965 219.989 0.0))
Specify point on side to offset: !PF2
(461.965 219.989 0.0)
Select object to offset or <exit>:
Command:
Anyway, I'm realy going home now!
Have a nice weekend! |
|
|
| Back to top |
|
 |
|
|
|
|