Jump to content

How can I calculate area by lisp?


Rain0923

Recommended Posts

Hi!!neophoible

Are you always selecting in pairs, except for the boundary divisors? -->

Yes,that are always selecting in pairs(about 5 pairs) then for the boundary divisors.

Can you have more than two divisors?

-->about two divisors

I know how to use AREA command but what is meaning using (getvar "AREA")??

 

pBe, actually, you could use the AREA command in the routine and retrieve the result using (getvar "AREA"), but I doubt that's your preference.

 

razara, it would be best if you show the output you are expecting for the sample drawing you have provided. Type it in just the way you want it to show.

Are you always selecting in pairs, except for the boundary divisors? Can you have more than two divisors?

Why not just explain what you are actually trying to accomplish with these calculations?

Link to comment
Share on other sites

  • Replies 28
  • Created
  • Last Reply

Top Posters In This Topic

  • Rain0923

    14

  • pBe

    9

  • neophoible

    5

  • Alex-77

    1

Top Posters In This Topic

Posted Images

That is correct neophoible, but might as well use the AREA command itself outside the routine for ADD/SUBTRACT and then run a short code for divide using (getvar 'area) [as you suggested] as an argument.
Yes, well, it depends on how lazy one wants to be in developing coding, or how skilled one is. For someone who knows very little about AutoLISP, they can still use the AREA command in single steps, retrieving and saving the Area using getvar each time. In this way, they can do whatever calculations they want, whenever they want, within the routine. It's nothing a purist would do, to be sure, but it would be simple.
Link to comment
Share on other sites

I know how to use AREA command but what is meaning using (getvar "AREA")??
If you get the Area of an object using the AREA command, you can then retrieve that latest value using (getvar "AREA"). This works not only within a routine, but you can also use this right on the command line. Try it. Use the AREA command first, then (getvar "AREA") at the next command prompt.

 

The function getvar retrieves values of system variables. "AREA" is the name of one of those system variables. For many system variables you can also set them using setvar. "AREA" is read-only, so you cannot change its value this way. If you want to know more about system variables and you have Express Tools, try _.sysvdlg on the command line.

Link to comment
Share on other sites

Are you always selecting in pairs, except for the boundary divisors?

-->Yes,that are always selecting in pairs(about 5 pairs) then for the boundary divisors.

Can you have more than two divisors?

-->about two divisors

If this is the case, then it would make sense to:

1. Prompt for two objects (select using any method; difference will be calculated as an absolute value--resultant area is always positive).

2. Continue this process until the user indicates he is finished.

3. Prompt to select the divisors (again, any method).

4. Do the calculations and report.

NOTE: If you need any intermediate calculations reported, then go ahead and say which ones now.

Link to comment
Share on other sites

I still can't know how to use (getvar "AREA"). sorry.......

I attach the file for I tried....

 

If you get the Area of an object using the AREA command, you can then retrieve that latest value using (getvar "AREA"). This works not only within a routine, but you can also use this right on the command line. Try it. Use the AREA command first, then (getvar "AREA") at the next command prompt.

 

The function getvar retrieves values of system variables. "AREA" is the name of one of those system variables. For many system variables you can also set them using setvar. "AREA" is read-only, so you cannot change its value this way. If you want to know more about system variables and you have Express Tools, try _.sysvdlg on the command line.

test.pdf

Link to comment
Share on other sites

Yes, it is what I needed as below you wrote.:)

 

If this is the case, then it would make sense to:

1. Prompt for two objects (select using any method; difference will be calculated as an absolute value--resultant area is always positive).

2. Continue this process until the user indicates he is finished.

3. Prompt to select the divisors (again, any method).

4. Do the calculations and report.

NOTE: If you need any intermediate calculations reported, then go ahead and say which ones now.

Link to comment
Share on other sites

I still can't know how to use (getvar "AREA"). sorry.......

I attach the file for I tried....

The Chinese characters make it a bit hard for me to follow, but it looks like you tried to use (getvar "AREA") inside the AREA command. This might work (I couldn't tell, as you did not show your results*), but what I meant was to enter it at the command prompt after finishing the AREA command (not at a sub-command prompt within the AREA command).

 

*Actually, it did work when I tried it, but it also messed up the rest of the command. It doesn't really matter, though, as you do not seem to know how to program AutoLISP. A routine would not be that difficult to write. I haven't the time just now, but if pBe hasn't come along and finished this for you soon, perhaps I will be able to hack out something for you.

Link to comment
Share on other sites

  • 3 weeks later...

Hi Hi!! neophoible

Sorry!!I just have Chinese version with my Auto CAD.

I tried use (getvar "AREA") again when after finishing the AREA command, but it

still can't use.:ouch:

It's so strange.....

 

The Chinese characters make it a bit hard for me to follow, but it looks like you tried to use (getvar "AREA") inside the AREA command. This might work (I couldn't tell, as you did not show your results*), but what I meant was to enter it at the command prompt after finishing the AREA command (not at a sub-command prompt within the AREA command).

 

*Actually, it did work when I tried it, but it also messed up the rest of the command. It doesn't really matter, though, as you do not seem to know how to program AutoLISP. A routine would not be that difficult to write. I haven't the time just now, but if pBe hasn't come along and finished this for you soon, perhaps I will be able to hack out something for you.

Link to comment
Share on other sites

1. calculate total red pline area

2. total red pline area / black pline area

How can I calculate area by lisp?

 

Possible solution:

1. Assign data "Red pline" to all red polylines,

2. Assign data "Black pline" to all black polylines,

3. Set the required units of measurement in the drawing,

3. Get the Total area specification for "Red plines" and "Black plines"

 

All this for a couple of minutes using "MeteorSpec" plug-in.

The app is available in Autodesk Exchange apps.

https://apps.exchange.autodesk.com/ACD/en/Detail/Index?id=appstore.exchange.autodesk.com:meteorspectrial_windows32and64:en

Link to comment
Share on other sites

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