Community
Civil 3D Forum
Welcome to Autodesk’s Civil 3D Forums. Share your knowledge, ask questions, and explore popular AutoCAD Civil 3D topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Lisp Routine help

9 REPLIES 9
SOLVED
Reply
Message 1 of 10
Anonymous
1646 Views, 9 Replies

Lisp Routine help

Hey all,

I have a lisp that used to work just fine before. It gave me quick acreage of an area and was useful for reference.
I am on Civil 3D 2020, and it appears to be broken. It keeps giving me a value of "0". I opened up Visual Lisp to inspect. Lisp follows:

(defun c:AC ()
(SETQ IP (GETPOINT " Pick Internal Point: "))
(COMMAND "-BOUNDARY" ip "")
(SETQ SS (ENTLAST))
(PROGN (COMMAND "AREA" "o" SS))
(SETQ acres (/ (GETVAR "AREA") 43560))
(SETQ Acres (rndby acres 0.001))
(setq ktext (strcat (rtos acres 2 2)" AC" ))
(setq ht 5)
(command "_.text" ip ht "0" ktext)


(princ)
)

(defun rndby (r b / tmp)
(setq tmp (rem r b))
(cond ((>= tmp (* 0.5 b)) (+ r (- b tmp)))
(T (- r tmp))))

I am trying to find the error in my programming, or a lisp that can do what this one can. Attached is also the Lisp file for those that prefer to mess with it in VLisp.

Thanks

 

Edit: Accidently escalated the topic. Eitherway, anyone's input will be helpful.

9 REPLIES 9
Message 2 of 10
Jowennl
in reply to: Anonymous

Hi @Anonymous ,

 

Can you please try the following attached Lisp below?

 

Sqft_to_Acre.gifSqft_to_Acre.gif

 

Original source of Lisp: Link

 

Cheers,

Jowenn

Message 3 of 10
Anonymous
in reply to: Jowennl

Okay so I tried both LSP files. Both are doing the same thing as my LSP. It gives me a value of 0 when I click inside, no decimal spots or anything. I attempted to make a larger square and check to see if precision was the issue, and it was not. They all keep giving me 0. 

Message 4 of 10
moogalm
in reply to: Anonymous

Hi,

 

In your code, try changing the tolerance from 0.001 to 0.0001

(SETQ Acres (rndby acres 0.0001))

 

Message 5 of 10
Anonymous
in reply to: moogalm

The text is still putting a zero as the output.

Message 6 of 10
moogalm
in reply to: Anonymous

Can you please share test drawing, I would like understand the drawing environment.

Are the coordinates of your PLINE is very far from origin ?, is it pure C3D drawing ?

Message 7 of 10
lynn_zhang
in reply to: Anonymous

Hello @Anonymous ,

Just checking to see if your problem has been solved. If not, please share the test drawing as mentioned by @moogalm so he can take a look and help you. Thanks!





Lynn Zhang
Community Manager


Message 8 of 10
Anonymous
in reply to: Anonymous

Good morning,

I have attached one of my sites, and the Lisp. Please let me know if anyone has ideas, thank you all!

Message 9 of 10
user181
in reply to: Anonymous

It is not because of Civil 3D 2020. It is because the current text style has an assigned height and the routine is written assuming a height of 0 is set for the current text style.

 

Either set the current text style to one with a height of zero before running the lsp or change the line:  

(command "_.text" ip ht "0" ktext)   to   (command "_.text" ip "0" ktext) to use a style with a height assigned.

 

Or modify the lisp to set a current text style and height. 

EESignature


Message 10 of 10
Anonymous
in reply to: user181

@user181 That was it! Thank you all for your help! this will make things a lot more efficient for those who don't know C3D Catchments!

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Rail Community


 

Autodesk Design & Make Report