Jump to content

Area w/Unit Conversion and optional Fields


Recommended Posts

Posted (edited)

Something I did at theswamp i thought i'd share here as well.

 

This routine labels objects at center and creates table, txt, or xls of areas.

 

Option for field usage available if object id successfully obtained

 

Unitlist includes:

(list "Sq Inches" "Sq Feet" "Sq Yards" "Acres" "Sq Miles" "Sq Millimeters" "Sq Centimeters" "Sq Meters" "Sq Kilometers")

 

Its been tested on acad 2008 thru 2010

 

Note: I haven't worked on obtaining a proper width to use in the tables for the field text strings.

AC_AREA-CALC_v1.3.lsp

Edited by jvillarreal
  • Replies 24
  • Created
  • Last Reply

Top Posters In This Topic

  • stevesfr

    7

  • jvillarreal

    7

  • BlackBox

    5

  • andyevans

    4

Posted

:: Danger, Will Robinson! ::

 

While many AutoCAD deployments utilize the default C:\Program Files\\Support\ folder for their mapped location to pull from ACAD.pat, this is not the case for all, and will result in an error if the local directory returned by (setq wPath (findfile "ACAD.PAT")) does not permit write access:

 

Command: ac

Object Filter [ ANY / POLYLINE / CIRCLE / ELLIPSE / REGION / SPLINE ]: <ANY>

Select objects: 1 found

Select objects:
button07 : button   { width = 7; alignment = centered; fixed_width = true; }
AreaCalc : dialog { label = "Results";
  :row {
    : text { label = "Prefix:" ; alignment = Centered; }
    : text { label = "Initial #:" ; alignment = Centered; }
  }
  :row {
    :edit_box { key = "Pfx"; alignment = centered; edit_limit = 18; edit_width 
= 18; }
    :edit_box { key = "init"; alignment = centered; edit_limit = 18; 
edit_width = 18; }
  }
  :row {
    :toggle { key = "kword"; label = "Label Areas";  alignment = center; }
:toggle { key = "fields"; label = "Use Fields";  alignment = center; }
  }
 :boxed_column { label = "Area Conversion";
    :popup_list { key = "Selection1"; label = "Convert From:" ;alignment = 
left; edit_width = 18;}
    :popup_list { key = "Selection2"; label = "Convert To:" ;alignment = left; 
edit_width = 18;}
    :edit_box { key = "Original"; label = "Total:"; alignment = left; 
edit_limit = 18; edit_width = 18; }
    :edit_box { key = "Converted"; label = "Converted:"; alignment = left; 
edit_limit = 18; edit_width = 18; }
  :row {
    :toggle { key = "include"; label = "Suffix";  alignment = center; }
    :popup_list { key = "Selection3";alignment = left; edit_width = 18;}
   }
 }
 :boxed_column { label = "Report Format";
    :popup_list { key = "Selection4"; alignment = left; edit_width = 18;}
 }
   : button07 { key = "accept"; label = "Done"; fixed_width = true ; alignment 
= centered; is_default = true; is_cancel = true; }
}

[color=red]<bad argument type: streamp nil>[/color]
[color=#ff0000][/color] 
Command:

Posted (edited)

I also noticed that after initial use of the program, if from or to was changed, the 'suffix' conversion factor wouldn't update unless a unit was manually selected from the suffix list.

The action_tile calls to the convert from and to popup lists (Selection1 and Selection2) were missing this line.

(if realconversion2 (setq realconversion2 (* (nth sfx conversionlist)(nth to inverseconversionlist))))

I've updated the post.

Edited by jvillarreal
Posted
Thanks for the heads up RenderMan.

 

You're welcome. :)

Posted

I get the following error when trying to run the lisp:

 

Command: ac

>

 

Don't have a clue what to look at in order to fix.

Steve

Posted
I get the following error when trying to run the lisp:

 

Command: ac

>

 

Don't have a clue what to look at in order to fix.

Steve

 

Step through the code within the VLIDE line by line to see where it bombs.

Posted

Makes no difference invoke lisp before or after selecting object....

 

running your suggestion at the command.... sheds no light...

 

Command: (defun GetObjectID ( obj doc)

(_> (if (vlax-method-applicable-p (vla-get-utility doc) 'Getobjectidstring)

((_> (vlax-invoke-method (vla-get-Utility doc) 'GetObjectIdString obj

:vlax-false)

((_> (itoa (vla-get-Objectid obj))

((_> )

(_> )

GETOBJECTID

Posted

Sorry, wouldn't have deleted the message had i known you responded. The selection of objects would have been obvious.

Enter "vlide" at the command line.

and paste this in (getobjectid (vlax-ename->vla-object (car (entsel))) (vla-get-ActiveDocument (vlax-get-Acad-Object)))

after hitting enter, select an object. What does it give you?

Posted

gives the following in vlide

 

_$ (getobjectid (vlax-ename->vla-object (car (entsel))) (vla-get-ActiveDocument (vlax-get-Acad-Object)))

_1$

no reaction in Acad when selecting object other than above in vlide

 

in a different trial in a new blank dwg, loading and running the lisp does produce the dcl file in the directory where acad.pat resides. Then when invoking the lisp and selecting an object, acad finds the dcl but its on the screen for only a millisecond and then the previous error statement appears. Why the dcl does not remain, is probably the problem to be investigated.

S

Posted (edited)

That line of code should've produced a string. If not, that's the error.

 

**Edit**

Removed code provided to steve as it was for testing purposes only.

Edited by jvillarreal
Posted
That line of code should've produced a string or nil. If not, that's the error.

 

Try this one out in a new drawing: [ATTACH]24514[/ATTACH]

 

Same result as "original" lisp. Tomorrow I'll try diff machine and diff acad version.... stay toooooned.

thanks very much for the efforts... help and suggestions.

Steve

  • 8 months later...
Posted

Just found this lisp and it is absolutely perfect for what I need it for, thanks for posting. Question is how easy would it be to modify to place the numerical area underneath the name within the polyline ?

 

Any help would be appreciated,.

 

Andy

Posted

too bad it doesn't work all the time, every time

Posted

Steve,

 

The version I have, 2.1, seems to be fairly robust. So far !

 

Andy

Posted
Steve,

 

The version I have, 2.1, seems to be fairly robust. So far !

 

Andy

 

Andy, can you provide a link to 2.1 ? ?

Steve

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