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

Construct wall centerline in the middle of wall

17 REPLIES 17
Reply
Message 1 of 18
shehab10
4270 Views, 17 Replies

Construct wall centerline in the middle of wall

Hello, i need a lisp that construct line between two lines of wall by selection called  (Wall Centerline)

i attach example of what i want assuming that i will often isolate wall layer in the project to facilitate the task.

17 REPLIES 17
Message 2 of 18
Kent1Cooper
in reply to: shehab10


@shehab10 wrote:

Hello, i need a lisp that construct line between two lines of wall by selection called  (Wall Centerline)

i attach example of what i want assuming that i will often isolate wall layer in the project to facilitate the task.


Are they Wall objects as in Architectural overlay programs?  If so, this might not work, and regardless, you would probably be better off building the centerlines into the definitions of the Wall objects if you can.  But if they're Lines or Polylines [or the same within Blocks, or just about any other straight entity], try the Bisector.lsp routine, with its BI command, here.  In the case of selection of two parallel straight objects, it draws an Xline halfway between them, i.e. bisecting the distance between them.  [If they're not parallel, it draws one bisecting the angle between them.]  You would still need to Trim and/or Fillet the resulting Xlines.

Kent Cooper, AIA
Message 3 of 18
shehab10
in reply to: shehab10

The walls are just lines (or sometimes poly lines)  they are not architectural object at all.

I saw bisecting lines i do not like it because it can not save time for me becuase i select line by line and then i make trim,fillet double work  :S

 

i saw before people did line between two lines but what i need here is multiple selection with one single line that is not being breaked in case there is door or window (let us say skipping block).

 

To be honest with you guys ,I will take those resulted lines from lisp to make from them walls in revit or autocad architecture by one single click in the other architecural programes that is why i need this beautiful lisp ! .

 

Message 4 of 18
bkp
Contributor
in reply to: shehab10

Can we not create an Multiline using mline in this case instead of making a lisp routine?

 

 

Message 5 of 18
jbuttsA5VXL
in reply to: shehab10

Was there ever a solution for this? I too am trying to create walls in REVIT automatically using ACAD centerlines but need a fast way to create centerlines.  Or if anyone has a different "automated" solution for creating walls in REVIT from a DWG file, sharing that would be much appreciated.

 

Thanks

Message 6 of 18
Sea-Haven
in reply to: jbuttsA5VXL

I don't use Revit but did you Google it should be possible to take a DWG line and make it a wall. The issue is that you will probably have to add the doors and windows again. As in a trace over scenario.

 

As a side note a method is to pick lines in sequence for each side 1 line only and offset a new cl and fillet etc as you go. So even though doors and windows a line would appear copyrighted solution.

 

screenshot204.png

 

 

Message 7 of 18
stevor
in reply to: shehab10

One way for 2D 'LINEs' is get the midpoints of 2 wall structures, ie,

2 parallel LINEs, make the parallel between LINEs and fillet the

'tween LINEs.

Use of SSGET "C" of appropriate size can get the wall lines.

S
Message 8 of 18
Sea-Haven
in reply to: stevor

stevor using ssget "F" works better for dragging over say 2 lines can get intersectwith of the crossing points so work out width of the wall section for a 1/2 width.

 

Unfortunately my solution is copyrighted will see if have time to do again.

 

 

Message 9 of 18
sby0531
in reply to: shehab10


@shehab10  已写:

Hello, i need a lisp that construct line between two lines of wall by selection called  (Wall Centerline)

i attach example of what i want assuming that i will often isolate wall layer in the project to facilitate the task.


Would you please upload some sample dwg files to draw wall centerlines in? I would like to try.

Message 10 of 18
kevin.anggrek
in reply to: shehab10

Same issue, we all need the LISP for this and actually I also need this to create the wall centerlines for automated REVIT wall generation. Has anyone find a solution and want to share it here once again? Thanks

Message 11 of 18
Sea-Haven
in reply to: kevin.anggrek

Is it Revit or Autocad dwg if so post sample.

Message 12 of 18
kevin.anggrek
in reply to: Sea-Haven

I have a CAD dwg that contains the floor plan of the building including wall lines. I am currently working on a Revit add-in to automate the process of generating the walls in Revit from 2D CAD drawing and finding the centerlines is vital because in order to create walls programmatically in Revit, the centerline of the walls is one of the input parameters.

 

My workflow consists of importing the CAD drawings into Revit and then running the Revit add-in. If the imported CAD drawings has the centerlines of the wall already, I can retrieve those centerlines and model the walls appropriately. Thus, if a LISP exists that can create wall centerline in the DWG file before importing to Revit (which is basically just as demanded by the thread starter), it would be great.

 

For sample, I have attached a simple floor plan drawing for testing.

 

In general, what I need to have is more or less the same as the starter of this thread. From the wall lines, I need to create the centerlines (colored red below):

centerline.png
Sorry if I sounded too demanding. I am open to different approach that will lead to a proper solution. Thank you

Message 13 of 18
Sea-Haven
in reply to: kevin.anggrek

You can 2 point drag over 2 lines so get all sorts of info start/end angle etc so I think it would be a bit like the MLINE options as sequences of building the centre line. 

 

Something like,  do drag start over 2 lines,  pick end/style I can see the most common would be start goes to end, "T", "+" etc, will have a think.

 

Kent may have done work on his prior offering.

 

screenshot364.png

Message 14 of 18
Sea-Haven
in reply to: Sea-Haven

This is just a start and will make the centreline very quick but it does not have any smarts that the part that needs a bit more thought I just find drag over a bit easier than two pick removes  the Missed pick problem.

 

Its a case of how to approach as asked before was just select all and magic happens. 

 

(defun c:test ( / pt1 pt2 pt3 pt4 obj oldsnap)
(setq oldsnap (getvar 'osmode))
(setvar 'osmode 0)

(if (tblsearch "layer" "CL")
(princ)
(command "-layer" "M" "CL" "C" 1 "CL" "")
)

(while (setq pt1 (getpoint "\nPick 1st point outside wall enter to exit "))
(setq pt2 (getpoint pt1 "\nDrag to pick 2nd  point "))

(setq ss (ssget "F" (list pt1 pt2)))

(setq ent1 (ssname ss 0))
(setq obj (vlax-ename->vla-object ent1))
(setq pt3 (vlax-curve-getclosestpointto obj pt1))

(setq ent2 (ssname ss 1))
(setq obj (vlax-ename->vla-object ent2))
(setq pt4 (vlax-curve-getclosestpointto obj pt1))

(setq dist (/ (abs (distance pt3 pt4)) 2.0))


(command "offset" dist ent1 pt2 "")
(command "chprop" (entlast) "" "LA" "CL" "")

)
(setvar 'osmode oldsnap)
(princ)
)

(c:test);(defun c:test ( / pt1 pt2 pt3 pt4 obj obj2 oldsnap ent1 ent2 dist ss)

(defun c:test ()
(setq oldsnap (getvar 'osmode))
(setvar 'osmode 0)

(if (tblsearch "layer" "CL")
(princ)
(command "-layer" "M" "CL" "C" 1 "CL" "")
)

(while (setq pt1 (getpoint "\nPick 1st point outside wall enter to exit "))
(setq pt2 (getpoint pt1 "\nDrag to pick 2nd  point "))

(setq ss (ssget "F" (list pt1 pt2)))
(if (= (sslength ss) 2 )
(progn
(setq ent1 (ssname ss 0))
(setq obj (vlax-ename->vla-object ent1))
(setq pt3 (vlax-curve-getclosestpointto obj pt1))

(setq ent2 (ssname ss 1))
(setq obj2 (vlax-ename->vla-object ent2))
(setq pt4 (vlax-curve-getclosestpointto obj2 pt1))

(setq dist (abs (/ (distance pt3 pt4) 2.0)))

(command "offset" dist ent1 pt2 "")
(command "chprop" (entlast) "" "LA" "CL" "")
)
(Alert "There are to many lines please check \n pick elsewhere")
)

)
(setvar 'osmode oldsnap)
(princ)
)

(c:test)

 

Now for bad news some of the lines are duplicated so maybe run Overkill 1st, pulling my hair out why not working now.

 

 

Message 15 of 18
kevin.anggrek
in reply to: Sea-Haven

I tested it and it works in the way that it can create single centerlines like this:

TestCenterline.png

TestCenterline2.png

Thank you for your help and efforts in making this. Thought this would be enough for now, I am looking for something that could be faster (for example like by selecting all of the walls and then create the centerlines at the same time). 

Message 16 of 18
Kent1Cooper
in reply to: kevin.anggrek


@kevin.anggrek wrote:

.... I am looking for something that could be faster (for example like by selecting all of the walls and then create the centerlines at the same time). 


I have a routine called BISECTOR.lsp with its BI command, available >here<.  It will do that kind of mid-line between any two straight things, whether Lines, Polyline line segments, such things inside Blocks, etc.  But it makes XLINEs, [which you would Fillet/Trim, but which also means multiple collinear wall segments can have their mid-lines drawn collectively from only one of the portions], and it does require picking individually on the two things.

 

However, to do what you're asking would be a hugely complicated challenge, if even possible.  It would require comparing every Line in the drawing to every other Line, deciding whether they're parallel and within some limit of distance apart [so it won't draw Lines through the center of rooms] and within some range of proximity to each other, and determining somehow whether the mid-line between them had already been drawn based on some Lines already considered, one of which might be the same as one of those currently under consideration.  Since not all the walls are the same thickness [though most are], there needs to be some range of allowable distance between parallel Lines, which would probably mean it would draw Lines down the middle of the width of all the steps, and literally thousands of Lines all over the apparent exploded Hatch pattern in the Car Parking area.

 

Just an example of some of the complications [I changed some colors for illustration]:

Kent1Cooper_1-1616673125380.png

To get a routine to realize that the mid-line between the red Lines and the one between the yellow Lines should be one resulting Line would be an enormously complex task.  And if it compares the yellow Lines before it gets to considering the green one [which we can't assume], the upper-yellow-to-green comparison involves something that's already been dealt with along with something that has not.  And that green Line's short length is likely to be within the range of possible wall thickness, so would it be removed from consideration, because it's likely to be an end-of-wall Line like the magenta ones?

 

Another:

Kent1Cooper_2-1616673647101.png

If you use @Sea-Haven's routine on the cyan and orange Lines, depending on the order in which you pick the ends of the fence, it can Offset either one, with different-length results.  If it does the cyan one, that covers the wall section between cyan and blue, so the blue Line should presumably be removed from consideration by an automating routine, but how can it do that when it's looking at the orange and cyan ones?  If it Offsets the orange one, when it gets to comparing cyan to blue, it might then Offset the cyan one, so there will be two partially-overlapping results.

 

I don't mean to sound discouraging, but to come up with something that would begin to do what you want would take more time than doing a very large number of these manually with a routine such as those already suggested to help, and some Fillet/Extend/Trim operations.

 

[By the way, the one Layer name suggests this plan comes from some on-line source of sample drawings.  I think you need to find a better source.  Everything is on the same Layer -- differentiating wall Lines from others would be a big start on making the work of a routine at least easier, if the other complications can be overcome.  There are duplicated Lines overlaying each other.  Many things about it are utterly unrealistic -- the exterior wall Lines run right across the window openings, the upper-middle bathrooms have only a single Line between them and the stair with no wall thickness, the stair has no openings into it (!) on either floor, the exterior walls are the same thickness as most of the interior partitions, etc., etc.]

Kent Cooper, AIA
Message 17 of 18
Sea-Haven
in reply to: Kent1Cooper

As you say Kent its a hard task pick short or long sides, I was thinking more like pick start wall, next wall is ?

 

For say fillet asks for next wall think outside walls then will fillet the second line created, for T looks for an existing wall c/l then pick new wall but will only extend 1 way, may need 2T. Oh yeah need dead end.

 

A lot of effort, I filleted and extended pretty quick.

 

May be a beer price tag.

Message 18 of 18
Sea-Haven
in reply to: Sea-Haven

This is still roough but added a couple of functions, for the wtee pick near Tee wall. As extend pick point must be on closer 1/2 way of a line.

 

; wall c/l by Alanh March 2021

(defun 2lines ( )
(setq pt2 (getpoint pt1 "\nDrag to pick 2nd  point "))
(setq ss (ssget "F" (list pt1 pt2)))
(if (= (sslength ss) 2 )
(progn
(setq ent1 (ssname ss 0))
(setq obj (vlax-ename->vla-object ent1))
(setq pt3 (vlax-curve-getclosestpointto obj pt1))
(setq ent2 (ssname ss 1))
(setq obj2 (vlax-ename->vla-object ent2))
(setq pt4 (vlax-curve-getclosestpointto obj2 pt1))
(setq dist (abs (/ (distance pt3 pt4) 2.0)))
(setq d1 (distance pt1 pt3)
	d2 (distance pt1 pt4)
)
(if (> d1 d2)
    (progn 
    (setq temp pt1)
    (setq pt1 pt2)
    (setq pt2 temp)
    )
)
(command "offset" dist ent1 pt2 "")
(command "chprop" (entlast) "" "LA" "CL" "")
)
(Alert "There are to many lines please check \n pick elsewhere")
)
)

(defun c:wf1 ( / ent ent2 )
(setvar 'filletrad 0.0)
(setq oldsnap (getvar 'osmode))
(setvar 'osmode 0)

(if (tblsearch "layer" "CL")
(princ)
(command "-layer" "M" "CL" "C" 1 "CL" "")
)

(if (= ent nil)
(progn
(setq pt1 (getpoint "\nPick 1st point inside wall enter to exit "))
(2lines)
(setq ent (entlast))
))
(while (setq pt1 (getpoint "\nPick 1st point outside wall enter to exit "))
(2lines)
(setq ent2 (entlast))
(setq st (cdr (assoc 10 (entget ent2))))
(setq end (cdr (assoc 11 (entget ent2))))
(setq mp (mapcar '* (mapcar '+ st end) '(0.5 0.5)))
(command "fillet" ent mp)
(setq ent ent2)
)
(setq ent nil)
)

(defun c:wtee ( / ent4 ent mp pt1 )
(setq oldsnap (getvar 'osmode))
(setvar 'osmode 0)

(if (tblsearch "layer" "CL")
(princ)
(command "-layer" "M" "CL" "C" 1 "CL" "")
)

(setq ent4(entsel "\Pick c/l to meet "))
(if (= ent nil)
(progn
(setq pt1 (getpoint "\nPick 1st point inside wall "))
(2lines)
(setq ent (entlast))
))

(command "line" pt1 pt2 "")
(setq obj (vlax-ename->vla-object (entlast)))
(setq obj1 (vlax-ename->vla-object ent))
(setq mp (vlax-invoke obj 'intersectWith obj1 acExtendThisEntity))
(command "erase" (entlast) "")
(command "extend" ent4 "" mp "")
(setq ent nil)
(setvar 'osmode oldsnap)
(princ)
)

(defun c:wcl ()
(while (setq pt1 (getpoint "\nPick 1st point outside wall enter to exit "))
(2lines)
)
)

(c:test)

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

Post to forums  

Autodesk Design & Make Report

”Boost