Jump to content

Edit to existing LISP routine


Spirax

Recommended Posts

Hi all,

 

Really need a hand here.

 

I have slightly edited the program from Lee Mac "areas2field" and added the line

 

(setq format "%lu2%pr2%ps[, ha]%ct8[0.0001]") ;; Field Formatting

 

This allows me to select a boundary and return the reading as an area in hectares, example output is "12.35 ha"

 

I would like to modify output to also convert to acres

for it to read like this "5.00 ac / 12.35 ha"

 

Appreciated your help in advance.

Link to comment
Share on other sites

BTW, I attempted something like this (setq format "%lu2%pr2%ps[, ac]%ct8[0.0002471044] / %lu2%pr2%ps[, ha]%ct8[0.0001]") ;; Field Formatting

Link to comment
Share on other sites

Your code snippet made me think otherwise, as the current code does not have a 'format' variable.

 

Nevertheless, as a quick fix, make the following changes:

 

Change Line 31 from:

    (setq fmt "%lu6%qf1") ;; Field Formatting

to:

    (setq fm1 "%lu6%qf1" ;; Field Formatting
         fm2 "%lu6%qf1"
   )

Change Lines 60-66 (inclusive) from:

                (setq str
                   (strcat
                       "%<\\AcObjProp Object(%<\\_ObjId "
                       (LM:ObjectID (vlax-ename->vla-object (ssname sel 0)))
                       ">%).Area \\f \"" fmt "\">%"
                   )
               )

to:

                (setq str
                   (strcat
                       "%<\\AcObjProp Object(%<\\_ObjId "
                       (LM:ObjectID (vlax-ename->vla-object (ssname sel 0)))
                       ">%).Area \\f \"" fm1 "\">%"
                       " / "
                       "%<\\AcObjProp Object(%<\\_ObjId "
                       (LM:ObjectID (vlax-ename->vla-object (ssname sel 0)))
                       ">%).Area \\f \"" fm2 "\">%"
                   )
               )

 

Change Lines 78-84 (inclusive) from:

                    (setq str
                       (strcat
                           "%<\\AcExpr "
                           (apply 'strcat (reverse (cdr (reverse lst))))
                           " \\f \"" fmt "\">%"
                       )
                   )

to:

                    (setq str
                       (strcat
                           "%<\\AcExpr "
                           (apply 'strcat (reverse (cdr (reverse lst))))
                           " \\f \"" fm1 "\">%"
                           " / "
                           "%<\\AcExpr "
                           (apply 'strcat (reverse (cdr (reverse lst))))
                           " \\f \"" fm2 "\">%"
                       )
                   )

 

And populate the variables fm1 and fm2 with the formatting for the fields on each side of the forward slash.

Link to comment
Share on other sites

Hi Lee,

 

Thanks very much for that. I have made those adjustments however it's not working for me.

 

I am not getting an error on load, it seems to work but is not output any text at all. It will realise I have selected an object then ask me where to place it, but shows up blank.

 

I have uploaded a copy here, https://pastebin.com/fVv7phXS

 

Could you please spot what I have done wrong?

Appreciate your help!

Link to comment
Share on other sites

I think you misunderstood my instruction: "And populate the variables fm1 and fm2 with the formatting for the fields on each side of the forward slash."

 

You should only change the values of fm1 & fm2, not substitute values where I have used these variables.

 

i.e. When I instructed: "And populate the variables fm1 and fm2 with the formatting for the fields on each side of the forward slash.", I meant that you should set this part:

 

    (setq fm1 "%lu6%qf1" ;; Field Formatting
         fm2 "%lu6%qf1"
   )

 

to your formatting of choice, e.g.:

 

    (setq fm1 "%lu2%pr2%ps[, ac]%ct8[0.0002471044]" ;; Field Formatting
         fm2 "%lu2%pr2%ps[, ha]%ct8[0.0001]"
   )

 

Sorry, I thought this was clear.

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