Jump to content

Recommended Posts

Posted
Code modified , try again ..:)

 

I think there is still something wrong because it doesn't give the radius of the arc but distance between the arrow and the arc? The placement of the arrow is also not on the arc self. :(

  • Replies 41
  • Created
  • Last Reply

Top Posters In This Topic

  • woohhoo

    12

  • alanjt

    9

  • Lee Mac

    7

  • Tharwat

    7

Top Posters In This Topic

Posted Images

Posted

@woohhoo:

 

The Dimension Text will be automatically oriented for readability; hence, for angles: π/2 3π/2, to the right.

Posted
Ok, I'm gonna try to explain it :cry:

 

1. when I draw an arc and the center of the arc is above the start and endpoint of the arc than the place of dimtext is ok.

2. when I draw another one but the center is under the begin and end point than the place of both dimtext is on the wrong side of the line.

3. When the center of the arc is left or right of the begin and endpoint than one of dimtext is good and the other one is again on the wrong side of the line.

 

I hope this would be helpful.

You posted a picture the first time, try it again. Better yet, post a DWG.
Posted
@woohhoo:

 

The Dimension Text will be automatically oriented for readability; hence, for angles: π/2 3π/2, to the right.

Is that what his problem is?

Posted
@woohhoo:

 

The Dimension Text will be automatically oriented for readability; hence, for angles: π/2 3π/2, to the right.

 

Ah, ok, so I guess it's not possible to place the text always between the dim lines.

Posted

Anyway, I really appreciate your efforts. I didn't know it wasn't possible.

 

:(

Posted
Anyway, I really appreciate your efforts. I didn't know it wasn't possible.

 

:(

 

It is possible if your willing to forced it, but that will be in contrast with general rule for dimensioning Here

Posted
It is possible if your willing to forced it, but that will be in contrast with general rule for dimensioning Here

 

The only reason I want to force it is that the other people will be able to interpret my drawing when there are several arcs connected. If it's not forced than dimensiontext will be placed upon eachother and it's not readable anymore. Therefore I tought it would be handy if it's always placed on the inside of the (arrow)lines.

I hope someone can help me. :unsure:

 

arctest1.dwg

 

Please take a look at the dwg.

Posted
The only reason I want to force it is that the other people will be able to interpret my drawing when there are several arcs connected. If it's not forced than dimensiontext will be placed upon eachother and it's not readable anymore. Therefore I tought it would be handy if it's always placed on the inside of the (arrow)lines.

I hope someone can help me. :unsure:

 

[ATTACH]31302[/ATTACH]

 

Please take a look at the dwg.

 

Kind of hacky, but it's working on my end...

 

(defun c:Test (/ *error* i ss e d o p r lst obj)

 (vl-load-com)

 (defun *error* (msg)
   (and *AcadDoc* (vla-endundomark *AcadDoc*))
   (if (and msg (not (wcmatch (strcase msg) "*BREAK*,*CANCEL*,*QUIT*,")))
     (princ (strcat "\nError: " msg))
   )
 )

 (vla-startundomark
   (cond (*AcadDoc*)
         ((setq *AcadDoc* (vla-get-activedocument (vlax-get-acad-object))))
   )
 )

 (if (setq i  -1
           ss (ssget '((0 . "ARC")))
     )
   (progn (while (setq e (ssname ss (setq i (1+ i))))
            (setq d (entget e)
                  o (vla-objectidtoobject *AcadDoc* (vla-get-ownerid (vlax-ename->vla-object e)))
                  p (cdr (assoc 10 d))
                  r (cdr (assoc 40 d))
            )
            (foreach point (list (polar p (cdr (assoc 50 d)) r) (polar p (cdr (assoc 51 d)) r))
              (setq lst (cons (vlax-invoke o 'adddimradial p point -1.) lst))
            )
          )
          (while (cadr lst)
            (setq obj (car lst))
            (foreach obj2 (setq lst (cdr lst))
              (if (vlax-invoke obj 'IntersectWith obj2 acExtendNone)
                (vla-put-verticaltextposition obj 4)
              )
            )
          )
   )
 )
 (*error* nil)
 (princ)
)

Posted
Kind of hacky, but it's working on my end...

 

(defun c:Test (/ *error* i ss e d o p r lst obj)

(vl-load-com)

(defun *error* (msg)
(and *AcadDoc* (vla-endundomark *AcadDoc*))
(if (and msg (not (wcmatch (strcase msg) "*BREAK*,*CANCEL*,*QUIT*,")))
(princ (strcat "\nError: " msg))
)
)

(vla-startundomark
(cond (*AcadDoc*)
((setq *AcadDoc* (vla-get-activedocument (vlax-get-acad-object))))
)
)

(if (setq i -1
ss (ssget '((0 . "ARC")))
)
(progn (while (setq e (ssname ss (setq i (1+ i))))
(setq d (entget e)
o (vla-objectidtoobject *AcadDoc* (vla-get-ownerid (vlax-ename->vla-object e)))
p (cdr (assoc 10 d))
r (cdr (assoc 40 d))
)
(foreach point (list (polar p (cdr (assoc 50 d)) r) (polar p (cdr (assoc 51 d)) r))
(setq lst (cons (vlax-invoke o 'adddimradial p point -1.) lst))
)
)
(while (cadr lst)
(setq obj (car lst))
(foreach obj2 (setq lst (cdr lst))
(if (vlax-invoke obj 'IntersectWith obj2 acExtendNone)
(vla-put-verticaltextposition obj 4)
)
)
)
)
)
(*error* nil)
(princ)
)

 

It's the same as before only the position of the dimtext are the opposite as before. Maybe the problem is my autocad configuration.

I really don't know anymore. :(

Posted (edited)

if you dont mind fudging the dimension string,

what we can do is determine the insertion point of dimension textstring is inside a triangle formed by

then

 
(vla-put-TextOverride ent (strcat "[url="file://xr/"]\\XR[/url][color=blue]<>[/color]")))

Edited by pBe
Posted
...Therefore I tought it would be handy if it's always placed on the inside of the (arrow)lines...

 

Create two buttons and assign these macros to switch the text:

 

^C^C_DIMOVERRIDE;DIMTAD;1;;

 

^C^C_DIMOVERRIDE;DIMTAD;4;;

Posted (edited)

I really don't know anymore. :(

 

what we can do is determine the insertion point of dimension textstring is inside a triangle formed by

then

 
(vla-put-TextOverride ent (strcat "[url="file://xr/"]\\XR[/url][color=blue]<>[/color]")))

 

To test this theory:

 

 
(defun c:Test (/ *error* i ss e d o p r lst obj)
;;;  Alanjt  ;;;  
 (vl-load-com)
(defun LM:GetDimensionString ( js / dl db ds )
;;; Lee Mac    ;;; 
 (if
   (and
     (wcmatch (cdr (assoc 0 (setq dl (entget js)))) "*DIMENSION")
     (setq db (tblobjname "BLOCK" (cdr (assoc 2 dl))))
   )
   (while (and (setq db (entnext db)) (not ds))
     (if (eq "MTEXT" (cdr (assoc 0 (setq dl (entget db)))))
       (setq ds (cdr (assoc 10 dl)))
     )
   )
 )
 ds
)
;; InsideTriangle-p  -  Lee Mac
;; Returns T if pt lies inside the triangle formed by p1,p2,p3  
(defun LM:InsideTriangle-p ( pt p1 p2 p3 )
   (
       (lambda ( a1 a2 a3 )
           (or
               (and (<= 0.0 a1) (<= 0.0 a2) (<= 0.0 a3))
               (and (<= a1 0.0) (<= a2 0.0) (<= a3 0.0))
           )
       )
       (sin (- (angle p1 pt) (angle p1 p2)))
       (sin (- (angle p2 pt) (angle p2 p3)))
       (sin (- (angle p3 pt) (angle p3 p1)))
   )
)
 (defun
    *error* (msg)
   (and *AcadDoc* (vla-endundomark *AcadDoc*))
   (if (and
         msg
         (not (wcmatch (strcase msg) "*BREAK*,*CANCEL*,*QUIT*,"))
         )
     (princ (strcat "\nError: " msg))
     )
   )
 (vla-startundomark
   (cond
     (*AcadDoc*)
     ((setq *AcadDoc* (vla-get-activedocument (vlax-get-acad-object)))
      )
     )
   )
 (if (setq
       i  -1
       ss (ssget '((0 . "ARC")))
       )
   (progn
     (while (setq e (ssname ss (setq i (1+ i))))
       (setq
         d (entget e)
         o (vla-objectidtoobject
             *AcadDoc*
             (vla-get-ownerid (setq e (vlax-ename->vla-object e)))
             )
         p (cdr (assoc 10 d))
         r (cdr (assoc 40 d))
         )
       (foreach
          point (list
                  (polar p (cdr (assoc 50 d)) r)
                  (polar p (cdr (assoc 51 d)) r)
                  )
;;;  Modified pBe  ;;;
         (setq nd (vlax-invoke o 'adddimradial p point -1.))
         (if (not
               (LM:InsideTriangle-p
                 (LM:GetDimensionString (vlax-vla-object->ename nd))
                 point
                 (vlax-curve-getPointAtParam
                   e
                   (/ (+ (vlax-curve-getEndParam e)
                         (vlax-curve-getStartParam e)
                         )
                      2
                      )
                   )
                 (vlax-safearray->list
                   (variant-value (vla-get-center e))
                   )
                 )
               )
           (vla-put-TextOverride nd "[url="file://\\X"]\\X[/url]<>")
           )
;;;  Modified pBe  ;;;
         )
       )
     )
   )
 (*error* nil)
 (princ)
 )

 

EDIT:Update Code

Edited by pBe
Posted

@pBe: First, thanks for including accreditation, much appreciated.

 

Just to make you aware that the middle point of the Dimension Text is DXF 11 of the Dimension DXF Data, might save you some code. ;)

Posted
@pBe: First, thanks for including accreditation, much appreciated.

 

You re welcome Lee ;)

 

(vla-put-TextOverride nd "\\X")

 

Just to make you aware that the middle point of the Dimension Text is DXF 11 of the Dimension DXF Data, might save you some code. ;)

 

 

Oh my.. you are right... btw what i'm looking for is a better formula for determining the location of the text. i thrown in a crappy test for distance for now (which is not foolproof)

 

A formula for "point inside the triangle" is my what i'm after really.

 

Diagram.png

 

if the text is outisde then apply the override

(vla-put-TextOverride nd "\\X")

 

any ideas?

 

----Math will be the death of me-----

Posted
A formula for "point inside the triangle" is my what i'm after really.

 

;; InsideTriangle-p  -  Lee Mac
;; Returns T if pt lies inside the triangle formed by p1,p2,p3

(defun LM:InsideTriangle-p ( pt p1 p2 p3 )
   (
       (lambda ( a1 a2 a3 )
           (or
               (and (<= 0.0 a1) (<= 0.0 a2) (<= 0.0 a3))
               (and (<= a1 0.0) (<= a2 0.0) (<= a3 0.0))
           )
       )
       (sin (- (angle p1 pt) (angle p1 p2)))
       (sin (- (angle p2 pt) (angle p2 p3)))
       (sin (- (angle p3 pt) (angle p3 p1)))
   )
)

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