View Full Version : Script / API to clean up “Line slightly off axis”
brenehan
2009-06-09, 09:58 AM
As we progress, we are inevitably using Revit in replacement of where we use to use AutoCad. We are now even using Revit for some master planning.
What this does mean, is we are having to use more and more AutoCAD (dwg) files in Revit. We need to be able to edit them and users want then in a Revit format, not just a linked dwg.
So we endeavour to clean the dwg files up before we bring it into Revit with tools like “Overkill, Audit, Purge”, rationalize the layers and hatching, remove floating elements outside the drawing area and I also filter and remove short lines relative to the scale.
What is more difficult is to fix lines that are 0.2 degrees off axis and 45 degrees, ie “Line slightly off axis” Currently I just have to import the file to Revit, explode and fix the errors. One of the last times I imported a file, I got 1300 lines slightly off axis. That is just too much to clean up.
Is there anyway someone with programming knowledge can come up with an AutoCAD lisp routine or a Revit API to fix the lines with an error up. It would need to find lines that are 0.2 degrees off 0, 45 and 90 degrees. These lines would then be rotated from their centre axis no more than 0.1 degree to 0, 45 or 90 Degrees or the other way to 0.201 degree of 0, 45 or 90 degrees.
I’ve looked for such a script without any luck. How difficult would it be to produce such a command?
Thanks
Brian
brenehan
2009-06-12, 07:27 AM
Is there anyway someone with programming knowledge can come up with an AutoCAD lisp routine or a Revit API to fix the lines with an error up.
Do you think this is possiable or just a pie in the sky wish?
d.stairmand
2009-06-12, 12:44 PM
Brian
I don't think its a Pie in the Sky - In fact it should be a utility on the Import "Clean up Import File" We get heaps of slightly incorrect cad files & only at the last stages of documentation find out where the errors are.
aaronrumple
2009-06-12, 01:33 PM
It would be a pretty simple routine to write in AutoCAD in either Lisp or VBA. It is just a matter of going through the collection of line and comparing the x,y coordinates of the endpoints of lines. You would just set a tolerance and compare. If they x values are within that tolerance, you would set then to the same value to square up lines. For angled lines you could do a similar check and set the correct x,y to give you a nice clean angle. The trick is picking a "good" value". You could add additional tests to see if any of the endpoints touch another line and then use that x,y as the control.
Plines would be a bit more code, but the technique the same.
However, this isn't going make sure the drawing is dimensionally correct - few AutoCAD drawings are.
travismv702230
2009-06-12, 02:08 PM
Having had to deal with this problem after the fact, I'd say make sure your AutoCAD drawing is drawn correctly. Since we know that won't happen, I'd say always check this out as soon as you link the file into Revit. Scripts and the like are above me but I'd be interested in a way to deal with something like this "automatically."
brenehan
2009-06-13, 01:52 AM
Thanks Guys
It’s good to know it’s possible. It’s the large scale maps we get (2 KM x 2 KM) that are the big headache. If you are just using them for master planning or just adjacent premises to your site, the fact some lines need to slightly rotated doesn’t really make any difference.
It’s a bit of a contradiction in terms for us (CAD & BIM Managers) to insist users are creating clean Revit files with minimum error warnings and not give them the tools to clean up an AutoCAD file they need to import. In reality we could turn that right around to Autodesk. They have created the software that gives up the error warning, they have given us the software that generates the warning, but they haven’t given us the tools to fix it.
So in the mean time, we (the users) will do, like we always do. The Users come up with a fix, and then wait for Autodesk to come out with something similar in the few years time.
Does anyone, with the programming knowledge think they would be able and have time to write such a script and share it here?
Thanks again.
Brian
truevis
2009-06-13, 02:52 PM
Here is a function I wrote in 1999 that identifies skewed lines. I haven't used it recently. I can be hired to customize it if anyone wants.
(defun c:skewedp (/ txtset total test ename
alist test update next fuzz-ask
ent-type)
(defun update (/ pt10 pt11 pt10x pt11x pt10y pt11y skewedp)
(setq pt10 (cdr (assoc 10 alist))
pt11 (cdr (assoc 11 alist))
pt10x (nth 0 pt10)
pt11x (nth 0 pt11)
pt10y (nth 1 pt10)
pt11y (nth 1 pt11))
(print ename)
(princ "Xs: ")
(princ pt10x)
(princ " ")
(princ pt11x)
(princ " Ys: ")
(princ pt10y)
(princ " ")
(princ pt11y)
(if (setq skewedp (or (and (equal pt10x pt11x fuzz)
(not (equal pt10x pt11x fuzz2)))
(and (equal pt10y pt11y fuzz)
(not (equal pt10y pt11y fuzz2)))))
(redraw ename 3))
(if skewedp
(princ " Skewed!"))
(setq test (1+ test)
ename (ssname txtset test))
(if ename
(setq alist (entget ename))))
(defun next ()
(setq test (1+ test)
ename (ssname txtset test))
(if ename
(setq alist (entget ename))))
(setq fuzz2 0.0000001)
(if (not fuzz)
(setq fuzz 0.2))
(setq fuzz-ask (getdist (strcat "\nMaximum checking distance. <"
(rtos fuzz)
">: ")))
(if fuzz-ask
(setq fuzz fuzz-ask))
(prompt
(strcat
"\nLines will be highlighted if ends are different less than "
(rtos fuzz 2 7)
" and different more than "
(rtos fuzz2 2 7)))
(setq txtset (ssget)
total (sslength txtset)
test 0
ename (ssname txtset 0))
(if ename
(setq alist (entget ename)))
(while (< test total)
(setq ent-type (cdr (assoc 0 alist)))
(if (= "LINE" ent-type)
(update)
(next)))
(princ))
Powered by vBulletin® Version 4.1.11 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.