iain9876 Posted July 17, 2008 Posted July 17, 2008 Hi guys, Does anyone know of a routine that would auto dimension lines. In my case the lines are a 2d triangular mesh. I have already tried the qdim command unfortunately this is not suitable as each line has to be dimensioned individually, also qdim mainly caters for linear dims which is not what I want. Anyone seen such a thing or know of it? thanks in advance Iain Quote
iain9876 Posted July 17, 2008 Author Posted July 17, 2008 Here is a drawing of a 2d triangular mesh. If anyone wants to write a program to autodimension each line in the dimaligned fashion. i would be most grateful even willing to pay cash. iain triangularmesh.dwg Quote
fixo Posted July 17, 2008 Posted July 17, 2008 To see the problem run this code from console ONLY on this drawing! (copy this code and past into editor) I can't fix it I used just A2008(eng) (defun C:test (/ elist en p1 p2 pc ss) (setvar "osmode" 0) (command "_.zoom" "_e") (setq ss (ssget "_X" (list (cons 0 "LINE")))) (setq i -1) (while (setq en (ssname ss (setq i (1+ i)))) (setq elist (entget en)) (setq p1 (cdr (assoc 10 elist)) p2 (cdr (assoc 11 elist)) pc (mapcar (function (lambda(a b)(/ (+ a b) 2))) p1 p2) ) (entmake (list (cons 0 "DIMENSION") (cons 100 "AcDbEntity") (cons 67 0) (cons 410 "Model") (cons 8 "ZONE1") (cons 100 "AcDbDimension") (cons 2 "*D0") (cons 10 (trans (list (car p2)(cadr p2) 0.0) 1 0)) (cons 11 (trans (list (car pc)(cadr pc) 0.0) 1 0)) (cons 12 (list 0. 0. 0.)) (cons 6 "Continuous") (cons 62 2) (cons 70 33) (cons 1 "") (cons 71 5) (cons 72 1) (cons 41 1.0) (cons 42 (distance p1 p2)) (cons 52 0) (cons 53 0) (cons 54 0) (cons 3 "Standard") (cons 100 "AcDbAlignedDimension") (cons 13 (trans (list (car p1)(cadr p1) 0.0) 1 0)) (cons 14 (trans (list (car p2)(cadr p2) 0.0) 1 0)) (cons 15 (list 0. 0. 0.)) (cons 16 (list 0. 0. 0.)) ) ) ) (alert "Look at this, what's wrong?") (princ) ) (C:test) (alert "There are all dims at the same point, what a ...???") ~'J'~ Quote
fixo Posted July 17, 2008 Posted July 17, 2008 I've found where was a mistake Give that a try instead (defun C:test (/ elist en p1 p2 pc ss) (setvar "osmode" 0) (command "_.zoom" "_e") (setq ss (ssget "_X" (list (cons 0 "LINE")))) (setq i -1) (while (setq en (ssname ss (setq i (1+ i)))) (setq elist (entget en)) (setq p1 (cdr (assoc 10 elist)) p2 (cdr (assoc 11 elist)) pc (mapcar (function (lambda(a b)(/ (+ a b) 2))) p1 p2) ) (entmake (list (cons 0 "DIMENSION") (cons 100 "AcDbEntity") (cons 67 0) (cons 410 "Model") (cons 8 "ZONE1") (cons 100 "AcDbDimension") (cons 10 (trans (list (car p2)(cadr p2) 0.0) 1 0)) (cons 11 (trans (list (car pc)(cadr pc) 0.0) 1 0)) (cons 12 (list 0. 0. 0.)) (cons 6 "Continuous") (cons 62 2) (cons 70 33) (cons 1 "") (cons 71 5) (cons 72 1) (cons 41 1.0) (cons 42 (distance p1 p2)) (cons 52 0) (cons 53 0) (cons 54 0) (cons 3 "Standard") (cons 100 "AcDbAlignedDimension") (cons 13 (trans (list (car p1)(cadr p1) 0.0) 1 0)) (cons 14 (trans (list (car p2)(cadr p2) 0.0) 1 0)) (cons 15 (list 0. 0. 0.)) (cons 16 (list 0. 0. 0.)) ) ) ) (alert "Done?") (princ) ) ~'J'~ Quote
iain9876 Posted July 18, 2008 Author Posted July 18, 2008 Fixo you are amazing! that routine just saved me a huge amount of time. do you have paypal? I know your not asking for anything, but its right I think that you should at least have a drink on me. Muchos Gracias iain Quote
fixo Posted July 18, 2008 Posted July 18, 2008 Forget about, Iain Next time you'll help to somebody else Happy to help, Regards, ~'J'~ Quote
buddygillespie Posted August 14, 2008 Posted August 14, 2008 Add this VBA sub routine to your acad.dvb and run it with the mesh drawing open. All dimensions will be aligned to each line entity... Just email me money in whatever amount you want...lol Public Sub DimAlignAll() Dim oAcEntity As AcadEntity 'use the current drawing thats open For Each oAcEntity In ThisDrawing.ModelSpace Select Case oAcEntity.ObjectName Case "AcDbLine" Dim oAcLine As AcadLine Set oAcLine = oAcEntity Dim aTxtPt(2) As Double aTxtPt(0) = oAcLine.StartPoint(0) aTxtPt(1) = oAcLine.StartPoint(1) With ThisDrawing.ModelSpace.AddDimAligned(oAcLine.StartPoint, oAcLine.EndPoint, aTxtPt) .Update End With End Select Next End Sub Quote
jessiwilk Posted August 9, 2011 Posted August 9, 2011 is this a lisp routine? and what is the command name? thnks. Quote
SLW210 Posted August 9, 2011 Posted August 9, 2011 Which one? fixo's is a LISP and buddygillespie's is VBA. Quote
BIGAL Posted August 10, 2011 Posted August 10, 2011 Copy and paste Fixo's code to notepad save the file as something.lsp Appload something.lsp then just type TEST all should happen Regarding VBA version VBAMAN then New then click on ACADproject then Visual basic editor then right button click this drawing .. View code, copy and paste the VBA code into the new window then save the VBA project "something" close the Visual basic window and return to Autocad to run, menu option, remove ^c^c for command line ^C^C(vl-vbaload "S:/AutoDESK/VBA/something.dvb") (vl-vbarun "DimAlignAll") Quote
tjfisher Posted July 12, 2013 Posted July 12, 2013 Fixo is there a way to alter this lisp routine so that the dimension location falls in a different location parallel to the line it is dimensioning but offset from it by say 200mm? or can this lisp be altered to a rotated dimension rather than an aligned one? To see the problem run this codefrom console ONLY on this drawing! (copy this code and past into editor) I can't fix it I used just A2008(eng) (defun C:test (/ elist en p1 p2 pc ss) (setvar "osmode" 0) (command "_.zoom" "_e") (setq ss (ssget "_X" (list (cons 0 "LINE")))) (setq i -1) (while (setq en (ssname ss (setq i (1+ i)))) (setq elist (entget en)) (setq p1 (cdr (assoc 10 elist)) p2 (cdr (assoc 11 elist)) pc (mapcar (function (lambda(a b)(/ (+ a b) 2))) p1 p2) ) (entmake (list (cons 0 "DIMENSION") (cons 100 "AcDbEntity") (cons 67 0) (cons 410 "Model") (cons 8 "ZONE1") (cons 100 "AcDbDimension") (cons 2 "*D0") (cons 10 (trans (list (car p2)(cadr p2) 0.0) 1 0)) (cons 11 (trans (list (car pc)(cadr pc) 0.0) 1 0)) (cons 12 (list 0. 0. 0.)) (cons 6 "Continuous") (cons 62 2) (cons 70 33) (cons 1 "") (cons 71 5) (cons 72 1) (cons 41 1.0) (cons 42 (distance p1 p2)) (cons 52 0) (cons 53 0) (cons 54 0) (cons 3 "Standard") (cons 100 "AcDbAlignedDimension") (cons 13 (trans (list (car p1)(cadr p1) 0.0) 1 0)) (cons 14 (trans (list (car p2)(cadr p2) 0.0) 1 0)) (cons 15 (list 0. 0. 0.)) (cons 16 (list 0. 0. 0.)) ) ) ) (alert "Look at this, what's wrong?") (princ) ) (C:test) (alert "There are all dims at the same point, what a ...???") ~'J'~ Quote
fixo Posted July 12, 2013 Posted July 12, 2013 tjfisher, Welcome on board! Please, attach a screenshot to make me more sense (.jpeg or .png availble in 'Go Advanced' tab) Quote
tjfisher Posted July 15, 2013 Posted July 15, 2013 Thanks Fixo. below i have drawn four lines and used the lisp routine to dimension the two on the left hand side and dimensioned the two right hand lines manually, as you can see the left hand dimensions are sitting directly on top of the line they are dimensioning, whereas the ones i did manually are offset from the line so that the line is still visible, any help would be appreciated tjfisher,Welcome on board! Please, attach a screenshot to make me more sense (.jpeg or .png availble in 'Go Advanced' tab) Quote
fixo Posted July 18, 2013 Posted July 18, 2013 @tjfisher sorry for the belating, try this code instead (defun C:mdm (/ elist en i p1 p2 pc ss) (command "_undo" "_be") (setq ss (ssget (list (cons 0 "LINE")))) (setq i -1) (while (setq en (ssname ss (setq i (1+ i)))) (setq elist (entget en)) (setq p1 (cdr (assoc 10 elist)) p2 (cdr (assoc 11 elist)) pc (mapcar (function (lambda(a b)(* (+ a b) 0.5))) p1 p2) ) (command "_dimaligned" "_non" p1 "_non" p2 "_non" pc ) (command "_dimtedit" "_L") (while (eq 1 (logand 1 (getvar "cmdactive")))(command pause)) ) (command "_undo" "_e") (princ) ) Quote
tjfisher Posted July 19, 2013 Posted July 19, 2013 @fixo thats great Fixo many thanks. just a minor question, is there anyway of keeping the dimension text centered on the dimension line? my dimension style is set to Text Placement, Horizontal: Centered, but the lisp routine seems to overide this? many thanks for your assistance Quote
fixo Posted July 19, 2013 Posted July 19, 2013 Try another routine, you can specify offset dimline from line entity transparently, say specifi direction and type gap size. I've added one line of code to set dimtext 'Home' : (defun C:mdm (/ elist en i p1 p2 pc ss) (command "_undo" "_be") (setq ss (ssget (list (cons 0 "LINE")))) (setq i -1) (while (setq en (ssname ss (setq i (1+ i)))) (setq elist (entget en)) (setq p1 (cdr (assoc 10 elist)) p2 (cdr (assoc 11 elist)) pc (mapcar (function (lambda(a b)(* (+ a b) 0.5))) p1 p2) ) (command "_dimaligned" "_non" p1 "_non" p2 "_non" pc ) (command "_dimtedit" "_L") (while (eq 1 (logand 1 (getvar "cmdactive")))(command pause)) (command "_dimtedit" "_L" "_H");<~~ code line added ) (command "_undo" "_e") (princ) ) Quote
tjfisher Posted August 6, 2013 Posted August 6, 2013 that great Fixo many thanks for your assistance Quote
fixo Posted August 6, 2013 Posted August 6, 2013 that great Fixo many thanks for your assistance You're welcome, I'm happy to help. Cheers Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.