Visual LISP, AutoLISP and General Customization

Visual LISP, AutoLISP and General Customization

Reply
Valued Contributor
GrzesiekGP
Posts: 67
Registered: ‎02-03-2012
Message 1 of 7 (514 Views)

Get coordinates for dimension's arrorheads.

514 Views, 6 Replies
07-14-2012 06:14 PM

Hello!

I'm writing function which will help user to offset dimension. After enter command, he select dimension and select point near one of dimension's arrowheads. Then I'm calculating new XLinePoint1 or XLinePoint2 and replacing original.

 

I have everything done. I thought ... The problem is when user firstly create AlignedDimension and after that he create RotatedDimension by using continous function. After that XLinePoint1 and XLinePoint2 are not parallel to the DimLinePoint (look at image).

 

Now I really don't have idea how to solve this problem.

 

Maybe someone know how can I get coordinates of points selected in red rectangles?

I know that one is specified as "dimension line defining point" but what about second? How can I get its coordinates?  Or maybe there is other way to get this point?

 

Thanks.

Distinguished Mentor
_Tharwat
Posts: 643
Registered: ‎07-02-2010
Message 2 of 7 (496 Views)

Re: Get coordinates for dimension's arrorheads.

07-14-2012 11:49 PM in reply to: GrzesiekGP

This would give you the location of the two arrow heads of the rotated and aligned dimensions to the command line .

 

(defun c:Test (/ d e)
  (vl-load-com)
;;; Tharwat 15. July. 2012 ;;;
 (if (and (setq d (car (entsel "\n Select dimension :"))) (or (equal "AcDbAlignedDimension" (cdr (assoc 100 (reverse (setq e (entget d))))) ) (equal "AcDbRotatedDimension" (cdr (assoc 100 (reverse e))) ) ) ) (vlax-for x (vla-item (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object)) ) (cdr (assoc 2 e)) ) (if (eq (vla-get-objectname x) "AcDbSolid") (print (vlax-safearray->list (vlax-variant-value (vla-get-coordinate x 3)) ) ) ) ) (princ "\n No selection , or its not a dimension ") ) (princ) )

 

____________________________________________________
Get learn and learn and practice , to become experienced guy .
Valued Contributor
GrzesiekGP
Posts: 67
Registered: ‎02-03-2012
Message 3 of 7 (491 Views)

Re: Get coordinates for dimension's arrorheads.

07-15-2012 12:49 AM in reply to: GrzesiekGP
I forgot to mention the most important thing - I'm writing in C# and now I don't have idea how to rewrite your code into C# :-(
Distinguished Mentor
_Tharwat
Posts: 643
Registered: ‎07-02-2010
Message 4 of 7 (489 Views)

Re: Get coordinates for dimension's arrorheads.

07-15-2012 12:56 AM in reply to: GrzesiekGP

It might be better to write your request in the correct froum that related to your needs of programming lnguage . and

unfortuneltly I have no idea about C# .

 

Tharwat

____________________________________________________
Get learn and learn and practice , to become experienced guy .
*Expert Elite*
Kent1Cooper
Posts: 5,879
Registered: ‎09-13-2004
Message 5 of 7 (476 Views)

Re: Get coordinates for dimension's arrorheads.

07-15-2012 05:13 AM in reply to: GrzesiekGP

GrzesiekGP wrote:

.... 

Maybe someone know how can I get coordinates of points selected in red rectangles?

I know that one is specified as "dimension line defining point" but what about second? How can I get its coordinates?  Or maybe there is other way to get this point?

....


I don't know C# either, but maybe it has something equivalent to entity data and the (inters) and (polar) Lisp functions, which can avoid the need to dig into a Dimension and look for Solids.  [The arrowheads will not always be Solids, anyway, or one may be and not the other, depending on arrow settings.]

 

This is a portion of a routine of mine [used to toggle extension lines on and off], which calculates the location of the other arrowhead ['data' is a variable containing the entity data for the selected Dimension]:

 

(setq
  def1 (cdr (assoc 13 data)); definition point 1
  def2 (cdr (assoc 14 data)); definition point 2
  ar2 (cdr (assoc 10 data)); arrow-point/end of dimension line at extension line 2
  dimdir ; direction of dimension line
    (if (= (cdr (assoc 70 data)) 33); aligned Dimension always has (50 . 0.0), so
      (angle def1 def2); then - direction between definition points
      (cdr (assoc 50 data)); else - direction of dimension line
    ); end if & dimdir
  ar1; other arrow-point/end of dimension line at extension line 1
    (inters
      ar2
      (polar ar2 dimdir 1); in direction of dimension line
      def1
      (polar def1 (angle def2 ar2) 1); in direction of extension lines
      nil
    ); end inters & ar1
); end setq

Kent Cooper
Distinguished Mentor
_Tharwat
Posts: 643
Registered: ‎07-02-2010
Message 6 of 7 (474 Views)

Re: Get coordinates for dimension's arrorheads.

07-15-2012 05:23 AM in reply to: Kent1Cooper

Kent1Cooper wrote:

 [The arrowheads will not always be Solids, anyway, or one may be and not the other, depending on arrow settings.]

 




That's correct , and I really did not notice that .

 

Thanks Kent

____________________________________________________
Get learn and learn and practice , to become experienced guy .
*Expert Elite*
Kent1Cooper
Posts: 5,879
Registered: ‎09-13-2004
Message 7 of 7 (449 Views)

Re: Get coordinates for dimension's arrorheads.

07-16-2012 08:21 AM in reply to: Kent1Cooper

Kent1Cooper wrote:

.... 

This is a portion of a routine of mine [used to toggle extension lines on and off], which calculates the location of the other arrowhead ....


By the way, that's for linear dimensions.  Arrowhead locations can be found by other means for angular dimensions, if you need to be able to do that.

Kent Cooper
Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Do you have 60 seconds to spare? The Autodesk Community Team is revamping our site ranking system and we want your feedback! Please click here to launch the 5 question survey. As always your input is greatly appreciated.