Quantcast
Channel: Recent Questions - Stack Overflow
Viewing all articles
Browse latest Browse all 12111

AutoCAD - Change Layer if Specific parameters are met

$
0
0

First time poster, hoping I could get some help because this is baffling me.

I have a layout with a boundary. After filling the boundary and cutting everything I sit with multiple closed polylines within the boundary.

Full Site Boundary

Small Section

As you can see from the images all the polylines are the same size and have a certain gap between them. Where the circle is, is basically a new set, so it does not form part of the above section.

I have a Layer for each number of closed polylines in a row. 1,2,3...etc up until 8. So 8 is max.

Now to the Question.....I need to write something that will be able to check and count the polylines and assign the correct layer to those closed polylines.

I should be able to write the code, but to honest I do not know how to go about this.

I have a Userform that currently does other functions, but it focusses mostly on quantitys and lengths. I would like to build on this so I'm looking for something that can be done in VBA.

PS. Everything is automated up until this point and I would like to keep it automated.

EDIT: I do not know where to start...(I'm Approaching it differently)

I adding a line that intersects 8 sets of plines when I populate the boundary, all I have to do now is check each line, count how many are bain intersected, then apply layer to each pline.

Pink Intersect Lines

This code below is what I'm busy with and trying to get what I want. The Code is not working in current form, it is just a representation of what I'm trying to do, Still figuring it out

    Sub addLayers()Dim intLine As AcadLineDim StringPLine As AcadLineDim CountString As LongDim acSelSet As AcadSelectionSetDim selObject As AcadEntity'///Looping thru each line in drawingFor Each intLine In ThisDrawing.ModelSpaceSet acSelSet = CreateSelectionSet("sset", ThisDrawing)'///Looping thru all polylines and checking if it intersects with LineFor Each StringPLine In ThisDrawing.ModelSpaceIf intLine.IntersectWith(StringPLine, acExtendNone) = True Then'///Add to selection setacSelSet.AddItems StringPLineEnd IfNext'///Looping thru each selected entityFor Each selObject In acSelSet'Add layer name to entityselObject.Layer = "0_" & acSelSet.count & "Strings"NextacSelSet.DeleteNextEnd Sub

WeTransfer link for Example.dwg File


Viewing all articles
Browse latest Browse all 12111

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>