Help with lisp routine

Help with lisp routine

Anonymous
Not applicable
560 Views
18 Replies
Message 1 of 19

Help with lisp routine

Anonymous
Not applicable
<<< Message <[email protected]> was originally posted to 'autodesk.aec.arch-desktop2' on Wed, 1 Mar 2000 11:14:47 -0500.>>>

I had a lisp routine that inserted an attribute.

Under Acad 14 after it was inserted a dialog box would come up to edit the
attribute.
Then the rest of the routine would finish up.

Undert ADT2 the program malfunctions.
The dialog box never comes up and in inserts the next string of text it
finds in the lisp file.
The routine never finishes .
Attdia is set to 1

Is there some other setting I am missing? or What.
0 Likes
561 Views
18 Replies
Replies (18)
Message 1 of 19

Anonymous
Not applicable
<<< Message <[email protected]> was originally posted to 'autodesk.aec.arch-desktop2' on Wed, 01 Mar 2000 10:41:01 -0600.>>>

I am having the same problem... and would like to know the answer as well...
in the mean time... I have incorporated a routine of my creation (with
variable number of edit boxes) that writes the dcl file and activates it on
the fly. When the user clicks the OK button it returns the user supplied
values. I then supply the strings to the insert command to fill the attribute
values at block insertion time.

But... would like to use the normal autocad method...?

David Fuller wrote:

> I had a lisp routine that inserted an attribute.
>
> Under Acad 14 after it was inserted a dialog box would come up to edit the
> attribute.
> Then the rest of the routine would finish up.
>
> Undert ADT2 the program malfunctions.
> The dialog box never comes up and in inserts the next string of text it
> finds in the lisp file.
> The routine never finishes .
> Attdia is set to 1
>
> Is there some other setting I am missing? or What.
0 Likes
Message 1 of 19

Anonymous
Not applicable
<<< Message <[email protected]> was originally posted to 'autodesk.aec.arch-desktop2' on Wed, 1 Mar 2000 12:20:40 -0800.>>>

try posting on the customization newsgroup
you probably need to precede your command with _-insert
nick
0 Likes
Message 1 of 19

Anonymous
Not applicable
<<< Message <[email protected]> was originally posted to 'autodesk.aec.arch-desktop2' on Wed, 1 Mar 2000 13:25:20 -0500.>>>

(setvar "ATTREQ" 1)
(setvar "ATTDIA" 1)
(initdia)
(command "-insert" .........)

--
Rob Starz
[email protected]
Plogv 3.0 & 2000 (plot logging) for r14 & 2000
ADT Curtainwall Suite
ADT Restroom Suite
**ADTcadPac coming soon**
http://www.stardsign.com/main.htm <
StarDsign cad solution
0 Likes
Message 1 of 19

Anonymous
Not applicable
<<< Message <[email protected]> was originally posted to 'autodesk.aec.arch-desktop2' on Wed, 1 Mar 2000 13:40:10 -0500.>>>

And you need to preceed the -insert with (initdia). This will force the
dialog box. For example:

(INITDIA)
(COMMAND "-INSERT" BLKNAME IP XSCALE YSCALE BLKANGLE)

--
Daniel J. Altamura, R.A.
Altamura Architectural Consulting
and SoftWorx, Autodesk Registered Developer
[email protected]

Nick August wrote in message <[email protected]>...
>try posting on the customization newsgroup
>you probably need to precede your command with _-insert
>nick
>
>
0 Likes
Message 6 of 19

Anonymous
Not applicable
I have a simple lisp routine which allows me to number up parking stalls -
and for some reason it's not working - my brain has been disabled from a
weekend of carousing - it must be something really simple that I'm
overlooking. Any help would be appreciated.

Thanks

Jamie Duncan


(defun c:FAIAPKNO (/ n1 n2 inc pt1 pt3 temp stallangle stallwidth)
(arctvsav) ; Save and set system variables

(setvar "cmdecho" 0)(setvar "osmode" 0)
(command "layer" "m" "CRONO" "")

(setq n1 (getint "\nEnter first number: ")
n2 (getint "\nEnter last number: ")
inc 1
pt1 (getpoint "\nSelect starting point: "))
(setvar "orthomode" 1)
(initget 1)
(setq pt3 (getpoint pt1 "\nPick direction for text: ")
stallangle (angle pt1 pt3))
(princ stallangle)
(if (= ARCTSTWD nil)(setq stallwidth (* ARCTSCALS 120.0))(setq stallwidth
ARCTSTWD));; global variable that sets stallwidths
(setq temp (getdist (strcat "\nDistance between text< " (itoa stallwidth)
" >: ")))
(if temp (setq stallwidth temp))

(while (<= n1 n2)
(command "text" "c" pt1 "" "0" (itoa n1))
(setq pt1 (polar pt1 stallangle stallwidth))
(setq n1 (+ n1 inc))
)
(arctvrst) ; Reset system variables
)
0 Likes
Message 7 of 19

Anonymous
Not applicable
Jamie,

Change the line:
(strcat "\nDistance between text< " (itoa stallwidth)" >: ")

To this:
(strcat "\nDistance between text< " (rtos stallwidth)" >:" )


Regards,
Steve Doman
0 Likes
Message 8 of 19

Anonymous
Not applicable
Thanks Steve,
I'm afraid this routine stubbornly refuses to work - I changed it as you
suggested and got a 0 for each number - if it's set to itoa the routine dies
before asking the stallwidth!

I'm resigned to being just clueless here.

Jamie

Steve Doman wrote in message
news:[email protected]...
>
0 Likes
Message 9 of 19

Anonymous
Not applicable
Does your current style have a fixed height? If so, it's reading the "0" for
the angle as the text itself, and ignoring the actual text. This is a major
annoyance with (command ...) and those AutoCAD commands that change syntax
depending on various conditions.
___

"Jamie Duncan" wrote in message
news:[email protected]...
> I changed it as you
> suggested and got a 0 for each number
0 Likes
Message 10 of 19

Anonymous
Not applicable
Shouldn't " layer" be "-layer"
Might Want to make a variable for the text height, Multiplying it by the
dimscale and substitute it for "" in the text command, just in case the
height is not set in the Style command or is 0

Steve

"Jamie Duncan" wrote in message
news:[email protected]...
> I have a simple lisp routine which allows me to number up parking stalls -
> and for some reason it's not working - my brain has been disabled from a
> weekend of carousing - it must be something really simple that I'm
> overlooking. Any help would be appreciated.
>
> Thanks
>
> Jamie Duncan
>
>
> (defun c:FAIAPKNO (/ n1 n2 inc pt1 pt3 temp stallangle stallwidth)
> (arctvsav) ; Save and set system variables
>
> (setvar "cmdecho" 0)(setvar "osmode" 0)
> (command "layer" "m" "CRONO" "")
>
> (setq n1 (getint "\nEnter first number: ")
> n2 (getint "\nEnter last number: ")
> inc 1
> pt1 (getpoint "\nSelect starting point: "))
> (setvar "orthomode" 1)
> (initget 1)
> (setq pt3 (getpoint pt1 "\nPick direction for text: ")
> stallangle (angle pt1 pt3))
> (princ stallangle)
> (if (= ARCTSTWD nil)(setq stallwidth (* ARCTSCALS 120.0))(setq stallwidth
> ARCTSTWD));; global variable that sets stallwidths
> (setq temp (getdist (strcat "\nDistance between text< " (itoa
stallwidth)
> " >: ")))
> (if temp (setq stallwidth temp))
>
> (while (<= n1 n2)
> (command "text" "c" pt1 "" "0" (itoa n1))
> (setq pt1 (polar pt1 stallangle stallwidth))
> (setq n1 (+ n1 inc))
> )
> (arctvrst) ; Reset system variables
> )
>
>
0 Likes
Message 11 of 19

Anonymous
Not applicable
Jamie,

I'm guessing the reason the code runs on my machine after making my
suggested fix, has something to do with those global variables the program
is using. I'm assuming that those globals are real numbers since they are
used as scalars.

Since you're still having problems, and because I thought this program might
be useful to myself, I took the liberty (and time) to rewrite the code. Now
I hope you don't take offense to what I've done, but my rearranging of the
code is primarilly for the purpose of checking the user input. It also
helps me to debug by formatting the code to my taste. You can change the
formatting to your taste if you want once we know it works on your machine.
I've also added a simple error routine to catch the error that occurs on the
event of the user hitting the ESC button.

I've also added a condition for handling fixed or nonfixed text height
(thanks to Paul Turvill for pointing that out). While I could have avoided
the fixed height condition (and layer making for that matter) by using the
'Entmake function, I left the text creation as was written (almost) so as to
not deviate to far from the original program, and to take advantage of
implementing a simple, yet cool little Undo feature.

The program runs well on my machine but consider it still a work in
progress. The undo feature for example, will bomb if undo happens to be
turned off. This can be fixed too but I leave that for another day.

If your still having trouble when running this version, then let us know as
best as you can what/when/how the error is occuring. Also let us know what
type of data any global symbols contain.

Please see attached file.

Regards,
Steve Doman


Jamie Duncan wrote:
> Thanks Steve,
> I'm afraid this routine stubbornly refuses to work - I changed
> it as you suggested and got a 0 for each number - if it's set
> to itoa the routine dies before asking the stallwidth!
>
> I'm resigned to being just clueless here.
>
> Jamie
0 Likes
Message 12 of 19

Anonymous
Not applicable
Hi Steve

Thanks - I figured out what was wrong with my function I was trying to apply
itoa to a real - didn't like it. Your enhancements to the function make it
much better.

Jamie Duncan

Steve Doman wrote in message
news:[email protected]...
>
0 Likes
Message 13 of 19

Anonymous
Not applicable
Jamie Duncan wrote:
> Thanks - I figured out what was wrong with my function I was trying to
apply
> itoa to a real - didn't like it.

That's what I was trying to say in my first reply to your post.

> Your enhancements to the function make it
> much better.

Glad you liked it. I'm going to use a variation of this routine to array
automatically incremented numbered text.

So Jamie, a question for you:

What does "FAIAPKNO" mean? Something, something, parking numbers? I'm not
an Architectural draftsman so if that's some kinda Architect lingo, I
wouln't know. Just curious.

Regards,
Steve Doman
0 Likes
Message 14 of 19

Anonymous
Not applicable
Hi Steve

We are an architectural firm (FAIA) and yes, it's for parking numbers. This
way we can easily number up spaces. We use an off the shelf 2D package
called ArchSoft which we have extensively enhanced. This autonumbering
routine was one of my first attempts at lisp - and thus as you noted was
rather primitive in terms of error handling etc.

Jamie Duncan

Steve Doman wrote in message
news:[email protected]...
>
0 Likes
Message 15 of 19

Anonymous
Not applicable
Can anybody help me with this lisp routine. I am new to lisp programming but
am willing to learn, I have attached the first few lines of a programme I am
tring to write. I want the routine to prompt me to pick a selection set of
text and then enclose all the selected text in brackets,

i.e.
pick 08
returns (08)

We import survey drawing information into our drawings and generally want
existing site levels to be enclosed in brackets to differentiate it from
proposed levels.

I realise the routine is miising som info but I'm at a loss of what the
programme needs to do next.

TIA

Chris


(DEFUN C:BRACKETS (/ TEXT)
(SETQ TEXT (SSGET))
(SETQ TEXT (strcat "(" TEXT ")")))
0 Likes
Message 16 of 19

Anonymous
Not applicable
Can anybody help me with this lisp routine. I am new to lisp programming but
am willing to learn, I have attached the first few lines of a programme I am
tring to write. I want the routine to prompt me to pick a selection set of
text and then enclose all the selected text in brackets,

i.e.
pick 08
returns (08)

We import survey drawing information into our drawings and generally want
existing site levels to be enclosed in brackets to differentiate it from
proposed levels.

I realise the routine is miising som info but I'm at a loss of what the
programme needs to do next.

TIA

Chris


(DEFUN C:BRACKETS (/ TEXT)
(SETQ TEXT (SSGET))
(SETQ TEXT (strcat "(" TEXT ")")))
0 Likes
Message 17 of 19

Anonymous
Not applicable
Can anybody help me with this lisp routine. I am new to lisp programming but
am willing to learn, I have attached the first few lines of a programme I am
tring to write. I want the routine to prompt me to pick a selection set of
text and then enclose all the selected text in brackets,

i.e.
pick 08
returns (08)

We import survey drawing information into our drawings and generally want
existing site levels to be enclosed in brackets to differentiate it from
proposed levels.

I realise the routine is miising som info but I'm at a loss of what the
programme needs to do next.

TIA

Chris


(DEFUN C:BRACKETS (/ TEXT)
(SETQ TEXT (SSGET))
(SETQ TEXT (strcat "(" TEXT ")")))
0 Likes
Message 18 of 19

Anonymous
Not applicable
(defun c:brackets ( / a b c d e f g n)
(princ "\nSelect text to enclose in brackets: ")
(setq a (ssget))
(setq b (sslength a))
(setq n 0)
(repeat b
(setq c (ssname a n))
(setq d (entget c))
(setq e (assoc 1 d))
(setq f (cdr e))
(setq g (strcat "\(" f "\)"))
(setq h (cons 1 g))
(setq d (subst h e d))
(entmod d)
(setq n (1+ n))
)
(princ)
)


"Chris" wrote in message
news:[email protected]...
> Can anybody help me with this lisp routine. I am new to lisp programming
but
> am willing to learn, I have attached the first few lines of a programme I
am
> tring to write. I want the routine to prompt me to pick a selection set of
> text and then enclose all the selected text in brackets,
>
> i.e.
> pick 08
> returns (08)
>
> We import survey drawing information into our drawings and generally want
> existing site levels to be enclosed in brackets to differentiate it from
> proposed levels.
>
> I realise the routine is miising som info but I'm at a loss of what the
> programme needs to do next.
>
> TIA
>
> Chris
>
>
> (DEFUN C:BRACKETS (/ TEXT)
> (SETQ TEXT (SSGET))
> (SETQ TEXT (strcat "(" TEXT ")")))
>
>
0 Likes
Message 19 of 19

Anonymous
Not applicable
(I forgot to sign it before sending)
By the way, since you're a lisp novice, I thought I'd leave the routine long
and clear to help you understand what is happening. Some parts of it may be
combined for a 'clean routine'.
~ Doug

"Doug Barr" wrote in message
news:[email protected]...
> (defun c:brackets ( / a b c d e f g n)
> (princ "\nSelect text to enclose in brackets: ")
> (setq a (ssget))
> (setq b (sslength a))
> (setq n 0)
> (repeat b
> (setq c (ssname a n))
> (setq d (entget c))
> (setq e (assoc 1 d))
> (setq f (cdr e))
> (setq g (strcat "\(" f "\)"))
> (setq h (cons 1 g))
> (setq d (subst h e d))
> (entmod d)
> (setq n (1+ n))
> )
> (princ)
> )
>
>
> "Chris" wrote in message
> news:[email protected]...
> > Can anybody help me with this lisp routine. I am new to lisp programming
> but
> > am willing to learn, I have attached the first few lines of a programme
I
> am
> > tring to write. I want the routine to prompt me to pick a selection set
of
> > text and then enclose all the selected text in brackets,
> >
> > i.e.
> > pick 08
> > returns (08)
> >
> > We import survey drawing information into our drawings and generally
want
> > existing site levels to be enclosed in brackets to differentiate it from
> > proposed levels.
> >
> > I realise the routine is miising som info but I'm at a loss of what the
> > programme needs to do next.
> >
> > TIA
> >
> > Chris
> >
> >
> > (DEFUN C:BRACKETS (/ TEXT)
> > (SETQ TEXT (SSGET))
> > (SETQ TEXT (strcat "(" TEXT ")")))
> >
> >
>
>
0 Likes