Jump to content

Recommended Posts

Posted

@marko_ribar: How about aligned or rotated dimensions?

 

Regards,

Mircea

  • Replies 43
  • Created
  • Last Reply

Top Posters In This Topic

  • MSasu

    14

  • pBe

    10

  • jan_ek

    10

  • Lee Mac

    4

Top Posters In This Topic

Posted Images

Posted

dimension2.gif

 

For me the point in the districts indicate

Posted

My approach:

(defun c:pointd ( / DimItem listEnt listPoints ) 
(if (setq DimItem (ssget "_:S:E" '((0 . "DIMENSION"))))
 (progn
  (setq listEnt (entget (ssname DimItem 0)))

  (if (member '(100 . (100 . "AcDbAlignedDimension")) listEnt)
   (if (member '(100 . "AcDbRotatedDimension") listEnt)
    ;;; Linear dimension (rotated or not)
    (setq listPoints (list (cdr (assoc 10 listEnt))
                           (polar (cdr (assoc 10 listEnt))
                                  (cdr (assoc 50 listEnt))
                                  (cdr (assoc 42 listEnt)))))
    ;;; Aligned dimension
    (setq listPoints (list (cdr (assoc 10 listEnt))
                           (polar (cdr (assoc 10 listEnt))
                                  (angle (cdr (assoc 14 listEnt))
                                         (cdr (assoc 13 listEnt)))
                                  (cdr (assoc 42 listEnt)))))
   )
  )
 )
)

(print listPoints)
(princ)
)
)

Regards,

Mircea

Posted

My version using vector calculus, quickly written:

 

(defun _dimensionpoints ( e / l v )
   (setq l (entget e)
         v (v1 (v^v (mapcar '- (cdr (assoc 14 l)) (cdr (assoc 10 l))) (cdr (assoc 210 l))))
   )
   (list
       (cdr (assoc 10 l))
       (mapcar '+
           (cdr (assoc 10 l))
           (vxs v (vxv (mapcar '- (cdr (assoc 13 l)) (cdr (assoc 14 l))) v))
       )
   )
)

;; Vector x Scalar  -  Lee Mac
;; Args: v - vector in R^n, s - real scalar

(defun vxs ( v s )
   (mapcar '(lambda ( n ) (* n s)) v)
)

;; Vector Dot Product  -  Lee Mac
;; Args: u,v - vectors in R^n

(defun vxv ( u v )
   (apply '+ (mapcar '* u v))
)

;; Unit Vector  -  Lee Mac
;; Args: v - vector in R^2 or R^3

(defun v1 ( v )
   (   (lambda ( n ) (if (equal 0.0 n 1e-10) nil (mapcar '/ v (list n n n))))
       (distance '(0.0 0.0 0.0) v)
   )
)

;; Vector Cross Product  -  Lee Mac
;; Args: u,v - vectors in R^3

(defun v^v ( u v )
   (list
       (- (* (cadr u) (caddr v)) (* (cadr v) (caddr u)))
       (- (* (car  v) (caddr u)) (* (car  u) (caddr v)))
       (- (* (car  u) (cadr  v)) (* (car  v) (cadr  u)))
   )
)

 

Test function:

 

(defun c:test ( / s p )
   (if (setq s (ssget "_+.:E:S" '((0 . "DIMENSION"))))
       (foreach p (_dimensionpoints (ssname s 0))
           (entmake (list '(0 . "POINT") (cons 10 p) '(62 . 30)))
       )
   )
   (princ)
)

Posted

msasu - his code works fine. Thank all for your help.

Please help in getting even the scale of that dimension.

Speaking of all the solutions - "wow"

Posted

msasu, I've changed code in post #20... Think that now is OK...

 

M.R.

Posted

@msasu,

 

I receive incorrect results for your code for rotated dimensions at zero rotation:

 

DimPts.png

Posted

@marko_ribar: I'm afraid you left one uncovered case - if the extension lines have different lengths.

 

Regards,

Mircea

Posted
I receive incorrect results for your code for rotated dimensions at zero rotation:

 

Oops! Seems that the rotation angle is retained with respect of order in which was indicated.

 

Regards,

Mircea

Posted

(defun punkt (listEnt / listPoints pa1 pa11 pa111 kata1)
(if (member '(100 . "AcDbRotatedDimension") listEnt)
   ;;; Linear dimension (rotated or not)
	(progn
		(setq pa1 (cdr (assoc 13 listEnt)) 
		pa11 (cdr (assoc 14 listEnt)) 
		pa111 (cdr (assoc 10 listEnt)) 
		kata1 (cdr (assoc 50 listEnt)) )
			(if (/= kata1 0.0)
				(progn
					(setq listPoints (list (list (car pa111) (car(cdr pa1)) 0)
							(list (car pa111) (car(cdr pa11)) 0)))
				)
				(progn 
					(setq listPoints (list (list (car pa1) (car(cdr pa111)) 0)
							(list (car pa11) (car(cdr pa111)) 0)))
				)
			)
	)
	(progn
	;;; Aligned dimension
	(setq listPoints (list (cdr (assoc 10 listEnt))
						   (polar (cdr (assoc 10 listEnt))
								  (angle (cdr (assoc 14 listEnt))
										 (cdr (assoc 13 listEnt)))
								  (cdr (assoc 42 listEnt)))))
   )
  )
  (setq listPoints  listPoints )
)

 

Sure I turned, and can be simply.Please provide comments and suggestions how to get the Scala this dimension.

Posted (edited)

Revised Code

 

(defun c:pointd  (/ _dxf _list [color=blue]_checksupp[/color] ss en ent pts)
(setq _dxf (lambda (dx en)
              (cdr (assoc dx (if (listp en) en
               (entget en))))))
(setq _list (lambda (p1 p2 d)
               (polar p1 (angle p1 p2)  d)))
[color=blue](defun _checksupp (e / val x)[/color]
[color=blue]    (setq val (mapcar '(lambda (x)(vlax-get e x))                     [/color]
[color=blue]'("ExtLine1Suppress" "ExtLine2Suppress")))[/color]
[color=blue]    (if  (zerop (setq x (apply '+ val))) 3[/color]
[color=blue]           (if (= x -2) 1 2))) [/color]

     (if (setq ss (ssget "_:S:E" '((0 . "DIMENSION"))))
           (progn
                 (setq en (ssname ss 0))
                 (setq ent (tblobjname "BLOCK" (_dxf 2 en)))
                 [color=blue](repeat (_checksupp (vlax-ename->vla-object en))[/color]
                       (setq ent (entnext ent)))
                 (setq pts  (list (_dxf 10 en)  
                                  (_list
                                        (_dxf 10 en)
                                        (_dxf 11 ent)
                                        (_dxf 42 en))))
                 )
           )
     pts
     )

 

EDIT: there is DXF 42 after all

EDIT: As per Lee's comment

Edited by pBe
_checksupp sub function
Posted (edited)
@marko_ribar: I'm afraid you left one uncovered case - if the extension lines have different lengths.

 

Regards,

Mircea

 

I am afraid that we all used (assoc 13 entlst) and (assoc 14 entlst), so neither code isn't fully correct... But I suppose that user won't change lengths of extension lines so that one is different than other one... So suppress extension lines is one option that comes to mind... Still that doesn't solve issue with Rotated and Linear dimensions, so my code is only applicable to Aligned dimensions... (And I usually use aligned dimensions just for that property that they have - equal lengths of extension lines -)

 

M.R.

Edited by marko_ribar
Posted
I am afraid that we all used (assoc 13 entlst) and (assoc 14 entlst), so neither code isn't fully correct...

 

My code should account for different extension line lengths.

 

                 (setq ent (tblobjname "BLOCK" (_dxf 2 en)))
                 (repeat 3 (setq ent (entnext ent)))

 

pBe, note that the order of objects in the Dimension Block definition will change depending on the Dimension Style, for example, when Extension Lines are suppressed.

Posted (edited)

pBe, note that the order of objects in the Dimension Block definition will change depending on the Dimension Style, for example, when Extension Lines are suppressed.

 

 

Thats what i figure from testing the code Lee. Thats why i posted this for the OP to verify

 

***I wonder if the OP had the ExtLine*Supress as true**** judigng by the posted picture i thinks its not,

 

Yeah, but it wouldnt hurt to make it generic. I'll get into that later. thank you for testing

Anything else you found that needed to be address?

 

CODE UPDATED: [#33]

Edited by pBe
Posted

Thanks for your time. I think I managed to get what I wanted.

Please help even with my last question, how to read scales indicated dimension.

Posted

Please help even with my last question, how to read scales indicated dimension.

 

Will it be included on the same lisp routine?

Are you using Annotative Dimensions?

Whats your current Linear unit convention?

Posted

I am talking about this property

skala.jpg

Posted
I am afraid that we all used (assoc 13 entlst) and (assoc 14 entlst), so neither code isn't fully correct...

 

I have used those only for aligned dimensions when the extension lines are always equals. I'm not saying that is wrong to use those codes for other cases, just need to account for the difference.

 

Regards,

Mircea

Posted
...
   (setq listPoints  listPoints )
)

You can write that simply:

 

...
listPoints
)

Regards,

Mircea

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