Jump to content

Recommended Posts

Posted

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

  • Replies 20
  • Created
  • Last Reply

Top Posters In This Topic

  • fixo

    8

  • tjfisher

    4

  • iain9876

    3

  • jessiwilk

    2

Top Posters In This Topic

Posted Images

Posted

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

Posted

Ok, I've got it

See you tomorrow

 

~'J'~

Posted

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'~

Posted

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'~

Posted

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 :D

Posted

Forget about, Iain

Next time you'll help to somebody else

Happy to help,

Regards,

 

~'J'~

  • 4 weeks later...
Posted

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

  • 2 years later...
Posted

is this a lisp routine? and what is the command name?

 

thnks.

Posted

Which one?

 

fixo's is a LISP and buddygillespie's is VBA.

Posted

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")

  • 1 year later...
Posted

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 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'~

Posted

tjfisher,

Welcome on board!

Please, attach a screenshot to make me more sense

(.jpeg or .png availble in 'Go Advanced' tab)

Posted

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 :)

 

Capture.jpg

tjfisher,

Welcome on board!

Please, attach a screenshot to make me more sense

(.jpeg or .png availble in 'Go Advanced' tab)

Posted

@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)
 )

Posted

@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 :D

Posted

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)
 )

  • 3 weeks later...
Posted

that great Fixo many thanks for your assistance :D

Posted
that great Fixo many thanks for your assistance :D

 

You're welcome,

I'm happy to help.

 

Cheers :beer:

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...