Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Lisp for length and width of multiple closed-polylines

14 REPLIES 14
SOLVED
Reply
Message 1 of 15
gavin9X6Z5
2577 Views, 14 Replies

Lisp for length and width of multiple closed-polylines

Hi Folks,

I'm doing a survey of heritage kerbs on a street half a kilometre long - that's a lot of kerbs. I'm required to number each kerb and record dimensions etc. I'm looking for a lisp that will extract the length and width (separately) of many closed polylines (which represents the kerb outline), preferably the lisp would allow multiple sections to speed things up. Also I will be numbering each kerb by placing mtext, if the lisp could correlate dimensions to mtext input and then extract to cad that would be fabulous!! 

Example of required excel tableExample of required excel tableExample of kerb surround in closed polyline.Example of kerb surround in closed polyline.

14 REPLIES 14
Message 2 of 15
Moshe-A
in reply to: gavin9X6Z5

@gavin9X6Z5  hi,

 

it looks very easy to do but it only looks. pity you did not post a sample drawing anyhow attached kerb.zip file contains 2 files: kerb.VLX and a block kerb_tag.dwg. extract these files to a library folder which is on your support files search path. load the lisp with appload. command to run KERB.

 

read these instructions very carefully:

the command starts with Select objects: let you to to select your polylines (kerbs). open polylines ignored (and you even will not notify about). the polylines must be from 4 points (those that are not simply rejected). polyline segment can be polyarcs.

 

than you require to select the first kerb (this is for numbering)

Select the first kerb:

 

than

Starting# <1>: < specify the starting number>

 

all the rest is done automatically. block kerb_tag will be insert in middle of kerb has 3 attributes the first called 'tag' (tag number) the second 'length' (is the length of the first polyline segment) the third 'width' (is the length of the second segment) if the segment is an arc it will return the arc length. length and width are invisible (but you can see them if you set ATTDISP to on). depending on how you draw the polylines you decide what is the length and what is the width. if the result is not what you expected, then reverse the polyline (PEDIT reverse). attributes base height is 0.2 drawing units and the block is inserted at scale multiplied by dimscale so you have to set a reasonable dimension style.

 

the second time you run KERB (and there are already some kerb_tags in), the starting number that will be at default is the last number incremented by 1.  if you want to rerun kerb on kerbs that is already done, include the kerb_tag blocks in your polylines selection (the old blocks will be replace with the new)

 

as i said my challenge was not easy but i stood it now it's your turn to create excel file as you wanted. you can do it with DATAEXTRACTION command...explore it.

 

enjoy

moshe

 

Message 3 of 15
gavin9X6Z5
in reply to: Moshe-A

Hi Moshe-A,

Thanks for getting back to me and for your very clear instructions, really appreciate it. I think this does exactly what we need. Just a couple of things I wonder could be ironed out if you had the time and the inclination?

  • Text-rotation - is it possible for text to align with whatever the ucs is set to?
  • Closed polyline with arc segment ignored - is possible to include in selection and also include a measure on the radius?
  • Numbering - due to the sheer number of kerbs the numbering will be alphabetical and numerical, so AE1, AE2 etc. Is it possible to facilitate this in the prompt? 

I've included a sample .dwg which may help you. Thanks again!!

Message 4 of 15
gavin9X6Z5
in reply to: Moshe-A

Hi again Moshe-A, hope I'm not pushing it now but I have another request,

Some of the kerbs are odd shapes, you might have one length longer than the other etc. so not symmetrical. Can the script dimension all 4 sides as well as a radius where applicable?

Message 5 of 15
Moshe-A
in reply to: gavin9X6Z5

@gavin9X6Z5  hi,

 

Sorry not replying yesterday, the program was not ready to deliver.

 

First some notes about your "18D16-Test File.dwg" :

the polyline with an arc has elevation this could cause the program to break so make sure you always draw on zero elevation. at the other side the top polyline is duplicate (you got there 2 polylines) the program does not search for duplication and you will end up with 2 tag on the same spot and more on that one it's build of 5 vertices (instead of 4) at the start there a 10 unit segment. you have to monitor such problems by your self.

 

Thanks for getting back to me and for your very clear instructions, really appreciate it. I think this does exactly what we need. Just a couple of things I wonder could be ironed out if you had the time and the inclination?

  • Text-rotation - is it possible for text to align with whatever the ucs is set to?
  • yes,  KERB does it's best to find the right angle to align the text (actually it's an attributes block) 
  • but it's not that easy at it looks like. we are talking about a polyline non symmetric shape, each segment could be at different angle and the question is at what angle the kerb is? so i established the kerb general direction by measuring the angle from current kerb centroid point to the next kerb centroid point. that raised another problem, the last kerb has no next kerb? so i set it's angle the same as it's previous and that influence on what kerbs you can select in one shot. select only kerbs that form a straight row this also ensures a sequential numbering,  if there is a change in direction, this should be another run.
  •  
  • Closed polyline with arc segment ignored - is possible to include in selection and also include a measure on the radius?
  • yes added this but i limited it to one arc segment cause i found that autolisp reports an invalid bulge angle (that's the included angle of the arc) which is need to calculate the radius so to solve this i had  to explode the polyline and look for that arc and get it's radius (this all done in the background, you won't  see noting Smiley LOL). 
  • Numbering - due to the sheer number of kerbs the numbering will be alphabetical and numerical, so AE1, AE2 etc. Is it possible to facilitate this in the prompt? 
  • yes you now have that, by default a prefix of 'AE' is added to the tag name. the prefix is stored in autocad system variable called USERS5 and you manually can set it to some other prefix if you like. the drawback of USERS5 is it is not saved in drawing database, so each run of KERB it is set to 'AE' only if you set it to something else before.

I've included a sample .dwg which may help you. Thanks again!!


Some of the kerbs are odd shapes, you might have one length longer than the other etc. so not symmetrical. Can the script dimension all 4 sides as well as a radius where applicable?

yes added that too.

 

the block kerb_tag now changed and contains 6 attributes (first is the tag and 5 edges). if arc segment found, the attribute edge(x) will contain the length of the arc plus it's radius. if you want to run the KERB new version on an existing drawing where you already run before, you need to delete all the exiting tags and purge it or do and update to the block tag (otherwise you will get mess Smiley LOL)

 

and something new:

KERBCSV is a command to write down to excel csv file all the attributes as you wanted.

 

enjoy

moshe

 

 

Message 6 of 15
Moshe-A
in reply to: gavin9X6Z5

Gavin,

 

made more fine tuning, are still interested?

 

moshe

 

Message 7 of 15
Moshe-A
in reply to: gavin9X6Z5

@gavin9X6Z5  hi,

 

check this update. if users5 is set (to some prefix) the default Starting# number would be to upper of that prefix

give also a try to KERBSCV command.

 

enjoy

moshe

 

Message 8 of 15
gavin9X6Z5
in reply to: Moshe-A

Hi Moshe-A,

I've attached the file below. A couple of screen grabs showing glitches I can't work out. Its ignoring two polylines and then swapping CW46 and CW47? It tried the kerbcvs and that works great, only thing it doesn't necessarily group the tags sequentially - CE1, CE20.....CE5 etc. Thanks.

Image 1.jpgImage 2.JPG

Message 9 of 15
Moshe-A
in reply to: gavin9X6Z5

Gavin,

 

here is an update and i solved all the issues (including kerbcsv) except one, a change in kerbs direction. you should run the kerb command on a row and stop at change direction, than continue to do the curved kerbs (2 to 3 polylines) and than next row. the reason for this is that the program knows to numerate  kerbs by sorting the plines distance from the first (you choose) and a change in direction might confuse that.  the beauty of the default number proposed to you now at Starting#  it quickly finds the last number according to the prefix in users5 such as you do not lost connection with the very last run.

 

wow turns out it become a big lisp Smiley LOL

 

enjoy

moshe

 

 

 

Message 10 of 15
gavin9X6Z5
in reply to: Moshe-A

Great Moshe-A, thanks for all your help on this, truly appreciated.

Message 11 of 15
Moshe-A
in reply to: gavin9X6Z5

@gavin9X6Z5 ,

 

forgot to say, in the last attachment you post you did not get all the edges measurement cause you forgot to update the block, hope now you are using the right block?!

 

and how kerbcsv working?

 

moshe

 

 

Message 12 of 15
gavin9X6Z5
in reply to: Moshe-A

Hi yes updated and all working perfect now included kerbcsv. Is there a way to control the tag size? I went into the block and tried to change the attribute size property but the tag stayed the same size upon exiting block editor.

Message 13 of 15
Moshe-A
in reply to: gavin9X6Z5

yes there is, after you change the attribute height use BATTMAN (or ATTSYNC) commands to populate this change to all attributes. my intention was to make the tag a little outstanding comparing to edges so reduce the edges size respectively.

 

soon i will post another update i'm fixing the prefix issue.now.

 

moshe

 

Message 14 of 15
Moshe-A
in reply to: gavin9X6Z5

@gavin9X6Z5 ,

 

the prefix is done. the default is 'AE'

the prefix must not end with a number but it could have numbers only not as the last character so it could be distinguish from the suffix number.

 

that's it Gavin ... it's prefect now Smiley LOL

 

moshe

 

Message 15 of 15
bananaking365
in reply to: Moshe-A

Hi @Moshe-A, thank you for making this VLX, it's going to be really helpful to what I want to achieve. However, I am getting the error message in the command history saying "can not find kerb_tag.dwg file." every time I tried to use the feature. I unzip the files into the same folder (both the .vlx and .dwg), do you know what might cause this problem?

 

Thanks in advance. 

 

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

Post to forums  

AutoCAD Inside the Factory


Autodesk Design & Make Report