Jump to content

Recommended Posts

Posted

Hello, i have a problem that i hope you guys can help me.

As attach i have a lsp file, some things on that code i made myself some others  took from the web, because i'm not that savvy with autocad lisp.

Basically what this lsp do is, measure all elements in an dwg and makes a xls file with the Layer; linetype, color and length for all lines, polylines and arcs.

All work well, but i need one simple thing that i can't manage to understand the  way to do it, i need to divide this lisp in to different commands like  "medzm" and "medzmm".

In "medzm" i need that the result equal as is is now, in the "medzmm" i need that  the length is divided by 1000.

 

Thanks for is advance for any help you can give.   

MedZ v3.lsp

Posted
2 hours ago, m1r said:

Hello, i have a problem that i hope you guys can help me.

As attach i have a lsp file, some things on that code i made myself some others  took from the web, because i'm not that savvy with autocad lisp.

Basically what this lsp do is, measure all elements in an dwg and makes a xls file with the Layer; linetype, color and length for all lines, polylines and arcs.

All work well, but i need one simple thing that i can't manage to understand the  way to do it, i need to divide this lisp in to different commands like  "medzm" and "medzmm".

In "medzm" i need that the result equal as is is now, in the "medzmm" i need that  the length is divided by 1000.

 

Thanks for is advance for any help you can give.   

MedZ v3.lsp

 

It all depends on whether your drawing units are in metres or millimetres. You could try checking sysvar "insunits" a value of 4 would indicate millimetres and a value of 6 metres. Experience tells me however that setting this to the correct value is often neglected.

 

If it is in metres then to convert to millimetres length = (* length 1000)

If it is in millimetres then to convert to metres length = (/ length 1000)

 

It would be exactly the same lisp file otherwise

Posted
5 minutes ago, dlanorh said:

 

It all depends on whether your drawing units are in metres or millimetres. You could try checking sysvar "insunits" a value of 4 would indicate millimetres and a value of 6 metres. Experience tells me however that setting this to the correct value is often neglected.

 

If it is in metres then to convert to millimetres length = (* length 1000)

If it is in millimetres then to convert to metres length = (/ length 1000)

 

It would be exactly the same lisp file otherwise

Thanks for the reply.

In this case the "insunits" var don't help, because some times as a client imposed limitation, i have to draw 1unit= 1m and some times 1000 unit's= 1m and the drawings are unitless , is easy for me in excel make this after running the lsp, just like you said / or * by 1000. But i would like to skip that extra step in excel.   

Posted
54 minutes ago, m1r said:

Thanks for the reply.

In this case the "insunits" var don't help, because some times as a client imposed limitation, i have to draw 1unit= 1m and some times 1000 unit's= 1m and the drawings are unitless , is easy for me in excel make this after running the lsp, just like you said / or * by 1000. But i would like to skip that extra step in excel.   

 

I was refering to the lisp code, not "excel" The lisp codes would be exactly the same for the two lisps bar one would divide or multiply the length returned in this line

 

 leng  (vlax-curve-getdistatparam pline (vlax-curve-getendparam pline))

This would be either

 

leng (* (vlax-curve-getdistatparam pline (vlax-curve-getendparam pline)) 1000)

OR

leng (/ (vlax-curve-getdistatparam pline (vlax-curve-getendparam pline)) 1000)

 

  • Thanks 1
Posted
3 hours ago, dlanorh said:

 

I was refering to the lisp code, not "excel" The lisp codes would be exactly the same for the two lisps bar one would divide or multiply the length returned in this line

 


 leng  (vlax-curve-getdistatparam pline (vlax-curve-getendparam pline))

This would be either

 


leng (* (vlax-curve-getdistatparam pline (vlax-curve-getendparam pline)) 1000)

OR

leng (/ (vlax-curve-getdistatparam pline (vlax-curve-getendparam pline)) 1000)

 

 

Sorry, my bad, i misunderstood that.

 

But yes,  your addon for the code works like a charm, now the lsp is working, and i can choose the proper scale as i ask for.

 

Many Thanks for the help. 5*

 

Posted (edited)

Attached is an updated lisp.

 

 This lisp will handle all cases - drawing units in metres or millimetres and distances in metres or millimetres.

 

I have carried out minimal testing with the lisp.

 

I have incorporated a local error routine.

 

I have incorporated using a dynamic prompt (if you aren't using it). This displays the choices to the two questions at the cursor as well as the command line, and resets at the end.

This asks for

1. the number of drawing units in 1 metre

2. whether you want the distances shown in millimeres or metres

To make this clear the "distancia" column will now show "distancia (mm)" or "distancia (m)"

 

I have adjusted the decimal places shown when converting from millimetre drawing units to metre lengths to 3 decimal places. This is automatic depending on what you select.

 

I have shifted the "release objects" code to it's own sub routine, allowing it to be called twice; once if it ends successfully and again if there is an error.

 

I have shifted out the collection of layer properties to it's own sub routine 

 

MedZ v5.lsp

Edited by dlanorh
spelling
  • Thanks 1
Posted
53 minutes ago, dlanorh said:

Attached is an updated lisp.

 

 This lisp will handle all cases - drawing units in metres or millimetres and distances in metres or millimetres.

 

I have carried out minimal testing with the lisp.

 

I have incorporated a local error routine.

 

I have incorporated using a dynamic prompt (if you aren't using it). This displays the choices to the two questions at the cursor as well as the command line, and resets at the end.

This asks for

1. the number of drawing units in 1 metre

2. whether you want the distances shown in millimeres or metres

To make this clear the "distancia" column will now show "distancia (mm)" or "distancia (m)"

 

I have adjusted the decimal places shown when converting from millimetre drawing units to metre lengths to 3 decimal places. This is automatic depending on what you select.

 

I have shifted the "release objects" code to it's own sub routine, allowing it to be called twice; once if it ends successfully and again if there is an error.

 

I have shifted out the collection of layer properties to it's own sub routine 

 

MedZ v5.lsp

 

What a great piece of work, nicely done, this works great.

I made a few adjustments to the code, for some things i prefer when working. If you can please check any conflict occurs with your code, as far i tested everything works well.

 

On the line (if (setq ss (ssget "_X" '((0 . "*LINE,ARC")))) i change it to   (if (setq ss (ssget '((0 . "*LINE,ARC")))), i want the ability to select what want on the drawing, most of time i need to make partial measurements on parts of the drawings. 

 

On the line (vlax-put-property xlCells "Item" row 4 (rtos (nth 3 x) 2 df)) i change it to (vlax-put-property xlCells "Item" row 4 (rtos (nth 3 x) 2 0)) , i prefer the precision to be 0, most of the time i'm making electrical drawings, i don't need so much precision, and makes easy on the grand total calculations, because in most cases i'm dealing with km's of cables for each drawing. 

 

Other than that it works great, i could ask more, you even make the code better.

 

Many thanks

 

MedZ v5.1.lsp

Posted
9 hours ago, m1r said:

On the line (vlax-put-property xlCells "Item" row 4 (rtos (nth 3 x) 2 df)) i change it to (vlax-put-property xlCells "Item" row 4 (rtos (nth 3 x) 2 0)) , i prefer the precision to be 0, most of the time i'm making electrical drawings, i don't need so much precision, and makes easy on the grand total calculations, because in most cases i'm dealing with km's of cables for each drawing. 

 

 

df is set to 0 except when your drawing is in millimetres and you want the lengths in metres, when it is set to 3. This is done automatically as the extra precision will be needed, but I didn't think this option would be used extensively.

 

Glad you like it.

Posted
On 11/3/2018 at 9:27 AM, dlanorh said:

 

df is set to 0 except when your drawing is in millimetres and you want the lengths in metres, when it is set to 3. This is done automatically as the extra precision will be needed, but I didn't think this option would be used extensively.

 

Glad you like it.

 

Sorry, now i realize that i can't put row 4 (rtos (nth 3 x) 2 0)) , because if i do that in cases that the value is 0,4 he rounds off to 0, and that not good, if i put DF was you suggest it works well but, now i have another issue. how do i make the lisp use "comma" instead of the "period" in the decimal separation?    

Posted
9 minutes ago, m1r said:

 

Sorry, now i realize that i can't put row 4 (rtos (nth 3 x) 2 0)) , because if i do that in cases that the value is 0,4 he rounds off to 0, and that not good, if i put DF was you suggest it works well but, now i have another issue. how do i make the lisp use "comma" instead of the "period" in the decimal separation?    

 

I would have thought that it is a microsoft system setting. I look later when I have more time.

Posted

OK,  simple solution. Your text is inserted as a string, so once it is converted to a string we need to search and replace the "." with a ",". Will sort this evening.

Posted
29 minutes ago, dlanorh said:

OK,  simple solution. Your text is inserted as a string, so once it is converted to a string we need to search and replace the "." with a ",". Will sort this evening.

Thanks.

Posted

Attached is updated Lisp v5-2.

 

The code now checks the lengths and total strings for any "." and replaces that with a "," using vl-string-subst. This will replace only the first occurance, and "There can be only One" (One of the best lines from "Highlander")

 

Hope this is OK.

 

MedZ v5-2.lsp

  • Thanks 1
Posted
15 hours ago, dlanorh said:

Attached is updated Lisp v5-2.

 

The code now checks the lengths and total strings for any "." and replaces that with a "," using vl-string-subst. This will replace only the first occurance, and "There can be only One" (One of the best lines from "Highlander")

 

Hope this is OK.

 

MedZ v5-2.lsp

 

Greetings

Only now I could check your code, and once again it's great, for all the tests i made, it seems working good.

I made some little adjustments to my personal preferences, i sending as attach the lsp with my mods, so you can keep it.

 

Once again, many thanks, great job 5*

MedZ v5.2.1.lsp

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