woohhoo Posted November 23, 2011 Author Posted November 23, 2011 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. Quote
Lee Mac Posted November 23, 2011 Posted November 23, 2011 @woohhoo: The Dimension Text will be automatically oriented for readability; hence, for angles: π/2 3π/2, to the right. Quote
alanjt Posted November 23, 2011 Posted November 23, 2011 Ok, I'm gonna try to explain it 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. Quote
alanjt Posted November 23, 2011 Posted November 23, 2011 @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? Quote
Lee Mac Posted November 23, 2011 Posted November 23, 2011 Is that what his problem is? Guess so, looking at the post here. Quote
woohhoo Posted November 24, 2011 Author Posted November 24, 2011 @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. Quote
woohhoo Posted November 24, 2011 Author Posted November 24, 2011 Anyway, I really appreciate your efforts. I didn't know it wasn't possible. Quote
pBe Posted November 24, 2011 Posted November 24, 2011 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 Quote
woohhoo Posted November 24, 2011 Author Posted November 24, 2011 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. arctest1.dwg Please take a look at the dwg. Quote
alanjt Posted November 24, 2011 Posted November 24, 2011 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. [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) ) Quote
woohhoo Posted November 24, 2011 Author Posted November 24, 2011 whilst i cant even open the file arctest1_2007.dwg Maybe this one? Quote
woohhoo Posted November 25, 2011 Author Posted November 25, 2011 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. Quote
pBe Posted November 25, 2011 Posted November 25, 2011 (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 November 26, 2011 by pBe Quote
GP_ Posted November 25, 2011 Posted November 25, 2011 ...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;; Quote
pBe Posted November 26, 2011 Posted November 26, 2011 (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 November 27, 2011 by pBe Quote
Lee Mac Posted November 26, 2011 Posted November 26, 2011 @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. Quote
pBe Posted November 26, 2011 Posted November 26, 2011 @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. if the text is outisde then apply the override (vla-put-TextOverride nd "\\X") any ideas? ----Math will be the death of me----- Quote
Lee Mac Posted November 26, 2011 Posted November 26, 2011 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))) ) ) 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.