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

Assigning attributes to blocks using polyline to sequence order

68 REPLIES 68
Reply
Message 1 of 69
Anonymous
4813 Views, 68 Replies

Assigning attributes to blocks using polyline to sequence order

Does anybody know of a routine that will allow to draw a polyline through existing blocks, in the order the blocks should be numbered? Therefore when the sequence has been specified by the polyline then user to define the number system required, and the blocks are automatically numbered in the sequence of the polyine start to finish. Smiley Indifferent

68 REPLIES 68
Message 61 of 69
Anonymous
in reply to: stevor

So you guys can see my problem. However, I have heard that you can run a pline and pick up the objects along its path. However you do not have to place a vertice at every object. I think it works more along the lines of the X,Y coordinates from vertice to vertice, calculating any of the block areas that the pline will pass through, hence creating an order!

 

Kev

Message 62 of 69
stevor
in reply to: Anonymous

That was done in my last post, in linear segments.  Several of us have done similar things before.

 

For you dwg, it looks like about 2/3rds of the INSERTs are not in 'rows' so my orthogonal 'Linear' approach is not quite right.

 

Thanks to some others code for the attribute processing, I am progressing anew, along a Pline based track for  indexing, so to speak.

 

For your project, as asked before, do you know if the features of the INSERTs that you will be modifying, i.e., the patterns of the strings?

 

 

S
Message 63 of 69
Kent1Cooper
in reply to: Anonymous


@Anonymous wrote:

.... I have heard that you can run a pline and pick up the objects along its path. However you do not have to place a vertice at every object. I think it works more along the lines of the X,Y coordinates from vertice to vertice, calculating any of the block areas that the pline will pass through, hence creating an order!

....


I think the way I would approach it would be:

 

Draw the Polyline, going around the route of intended sequencing, and at least being close to each Block, that is, so that each Block is closer to the "right" place on the Polyline than it is to any other part of it passing nearby.

 

Make a selection set of all the applicable Blocks.

 

Step through that set [or a list made from it], and for each Block:

::  use (vlax-curve-getClosestPointTo) to find the point on the Polyline closest to the Block's insertion point;

::  use (vlax-curve-getDistAtPoint) or (vlax-curve-getParamAtPoint) to find where that is along the Polyline;

::  pair the Block's entity name with that Distance or Parameter value in a two-element list, and put that into a larger list.

 

Sort that larger list of Block-and-where lists in ascending order of Distance or Parameter values.

 

Step through the sorted list to assign the incremented numbers in their longer strings to the identifier Attribute in each.

 

[I think the sequencing could also be done without re-arranging the order of things in the larger list, by using (vl-sort-i) to get a list of index numbers, and using (nth) with that list to work through the larger list.]

Kent Cooper, AIA
Message 64 of 69
Kent1Cooper
in reply to: stevor


@stevor wrote:

.... do you know if the features of the INSERTs that you will be modifying, i.e., the patterns of the strings?


It could be built to select from a few standardized options as in one of my earlier posts, or if there are no really standard ways [the sample drawing's format isn't the same as any of the three options in an earlier message], simply to ask the User to spell out what to put before the incrementing part, and what to put after it [if anything], and whether the incrementing parts should be 3-digit numbers, or ranges as in the sample drawing.

Kent Cooper, AIA
Message 65 of 69
stevor
in reply to: Anonymous

Was this the intent?

 

S
Message 66 of 69
wkiernan
in reply to: Kent1Cooper

Sounds great, you could use GetBoundingBox on each of the entities first to get the "center" of the entity, then with vlax-curve-GetClosestPointTo you could get the closest point to that "center" on the polyline, then you could look at that bounding box and see if the closest point on the polyline falls inside the entity's bounding box, and if it does use vlax-curve-GetParamAtPoint to find the nearest's point's position on the polyline (what we land surveyors call its "station" along the pline).  Compile a list of sublists in the format ((station ename)(station ename)...), sort by station, step through the sorted list sequentially updating the ATTRIBs attached to each entity name. 

 

What you'd end up with is a routine that, first, asks the user to pick a typical INSERT of the ones you want to update (to get its BLOCK name), then prompts you to draw a pline though the various INSERTs, hitting them in the order you want them renumbered.  Now it goes through the list of all the INSERTs with that BLOCK name, compiles that list for the ones where the nearest point on the pline to the "center" of the bounding box falls inside that bounding box, sorts the list in order of position along the pline, and then increments the ATTRIBs accordingly.

Message 67 of 69
stevor
in reply to: wkiernan

Sorry Wkiernan, could not make it thru your discourse. I used ssget with "f" for fence, as I recall, for the attached example.

S
Message 68 of 69
Anonymous
in reply to: Anonymous

Hi Guys,

 

Sorry guys got moved off my project.

 

Yes Stevor that is exactly it that you draw a polyline through the blocks in the sequence that you would like them numbered.

 

regards

 

Kevin

 

P.S. Have a Merry Xmas and A Prosperous New Year, and thanks for all your help. Hopefully I will be able to crack this in 2012!!

Message 69 of 69
3wood
in reply to: Anonymous

Please try the new fuction - Sort selection "Along paths" in ALTEXT.vlx.

I believe it is what you was looking for.

 

3wood

CAD KITS

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

Post to forums  

Autodesk Design & Make Report

”Boost