Jump to content

Modify a rotated dimension property


guitarguy1685

Recommended Posts

I'm writing a lisp that will change the one end of a rotated dimension to an Arrowhead with Extension line suppressed. I don't think i'll have a problem modifying those properties, what I'm stuck on in my though process is how to change the property of the select end.

 

what i mean is this. Every rotated dim has two sides to it. Extension1 and Extension2, Arrow1 and Arrow2, etc. I can set my lisps to modify either side, but when I look at a dim I don't know if the left is side 1 or 2. I wont know until I run the lisp.

 

Is there a way I can see what side I picked via lisp? Like if I selct on the left side of the dim, the lisp will know that side is 1 or 2? Then I can set a if/then statement to modify the selected side.

Link to comment
Share on other sites

Try to measure the distance between the picked point and the DXF codes 13 & 14 so the smallest distance must be the one that is picked.
This is not always true for rotated dimensions.

 

Comparing the distance from the picked point to the gc 10 definition point of the dimension against the actual dimension (gc 42) is more reliable. This definition point lies on the dimension line and the 2nd extension line.

Link to comment
Share on other sites

good ideas here. I'll try both.

 

Roy, using your method I think I would have to pick on the dimline. If I try Tharwat's I can pick on either the dimline or extension line. Am I wrong?

Link to comment
Share on other sites

here is my solution. I used Tharwat's method. seems pretty reliable so far.

 

(defun C:DimRef (/ acadobj acaddoc dim dimdxf dimobj dimpt
       dimpt1 dimpt2 dist1 dist2)
 (vl-load-com)
 
 (setq acadobj (vlax-get-acad-object)
acaddoc (vla-get-activedocument acadobj)
)
 (setq dim 	(entsel)
dimdxf	(entget (car dim))
dimobj	(vlax-ename->vla-object (car dim))
dimpt	(cadr dim)
dimpt1	(cdr (assoc 13 dimdxf))
dimpt2	(cdr (assoc 14 dimdxf))
dist1	(distance dimpt dimpt1)
dist2	(distance dimpt dimpt2)
)

 (if
   (not *ExtLtype)
   (setq *ExtLtype "ByBlock"
  )
   )
 
 (initget "Center2 BybLock")
 (setq *ExtLtype
 (cond
   ((getkword (strcat "\nExtension line linetype [Center2/Byblock]: <" ">: ")))
   (*ExtLtype)
   )
)


 (if
   (= (tblsearch "Block" "_ClosedFilled2X") nil)            ;[color="red"]this is a custom block[/color]
   (vl-cmdf "_.insert" "_ClosedFilled2X" "0,0,0" "" "" ""
     "_.erase" "L" "")
   )
 ;(load "LM_LoadLinetypes.lsp")   [color="red"];this is code from Lee Mac's to load Linetypes if they don't exist. site.[/color]
 ;(LM:loadlinetypes '("Center2") nil)

 (if
   (< dist1 dist2)
   (progn
     (vlax-put-property dimobj 'Extline1Suppress :vlax-true)
     (vlax-put-property dimobj 'Arrowhead1Block "_ClosedFilled2x")
     (vlax-put-property dimobj 'Extline2Suppress :vlax-false)
     (vlax-put-property dimobj 'Arrowhead2Block "_Oblique")
     (if
(= *ExtLtype "Center2")
(vlax-put-property dimobj 'ExtLine2Linetype "CENTER2")
(vlax-put-property dimobj 'ExtLine2Linetype "ByBlock")
)
     )
   (progn
     (vlax-put-property dimobj 'Extline2Suppress :vlax-true)
     (vlax-put-property dimobj 'Arrowhead2Block "_ClosedFilled2x")
     (vlax-put-property dimobj 'Extline1Suppress :vlax-false)
     (vlax-put-property dimobj 'Arrowhead1Block "_Oblique")
     (if
(= *ExtLtype "Center2")
(vlax-put-property dimobj 'ExtLine1Linetype "CENTER2")
(vlax-put-property dimobj 'ExtLine1Linetype "ByBlock")
)
     )
   )
 
 (vlax-put-property dimobj 'TextOverride "REF DIM. SEE PLAN")

 )

 

There is one little bug that is bugginb that I'll ask in another thread.

 

Thanks for the ideas guys.

Link to comment
Share on other sites

Tharwat's method is reliable for aligned dimensions where the dimension line is always parallel to the line between the dimensioned points. But not for rotated dimensions.

 

To improve on my previous suggestion:

 

  1. You already have the intersection of the dimension line and the 2nd extension line (gc 10).
  2. With that point, gc 42 and gc 50 (the angle of the dimension line) you can calculate the intersection of the dimension line with the 1st extension line.
  3. Comparing the distances of the selected point with those two intersection points should work.
  4. Of course there are coordinate system issues that have to be taken into account...

Link to comment
Share on other sites

Tharwat's method is reliable for aligned dimensions where the dimension line is always parallel to the line between the dimensioned points. But not for rotated dimensions.

 

 

Though I'd check in. You were rigt Tharwat, it does appear to be more reliable using the end of the dimension line.

 

This is what I ended up with.

 

;;--------------------------------------------------------------;;
;;		Refrence Dimension				;;
;;--------------------------------------------------------------;;

(defun C:DimRef(/ #Osmode *error* LtypeAns dim dimdxf dimobj dimpt dimpt2 dist)

 (setq #Osmode (getvar 'Osmode))
;--------------error handler----------------------------;
 (defun *error* ( msg )
   (setvar 'Osmode #Osmode)
   (princ (strcat "\nError: " msg))
   )
;-------------------------------------------------------;
 
 (if								;this will set a default linetype
   (not *ExtLtype)
   (setq *ExtLtype "ByBlock")
   )
 
 (initget "Center2 ByBLock")				;this portion to select extension linetype
 (setq LtypeAns (getkword (strcat "\nExtension line linetype [Center2/ByBLock] <" *ExtLtype ">: ")))
 (if
   (/= LtypeAns "")
   (setq *ExtLtype LtypeAns)
   )   

 (if						;inserts the custom arrowhead block
   (= (tblsearch "Block" "_ClosedFilled2X") nil)
   (vl-cmdf "_.insert" "C:\\CAD\\Blocks\\Annotation\\_ClosedFilled2X" "0,0,0" "" "" ""
     "_.erase" "L" "")
   )
 
 (load "LM_LoadLinetypes.lsp")		;subroutine to load ltypes if they do not exists.  Thanks Lee-Mac
 (LM:loadlinetypes '("Center2") nil)

 (while				;main part of program.
   (setq dim 		(entsel))
   (setq dimdxf	(entget (car dim))
  dimobj	(vlax-ename->vla-object (car dim))
  dimpt		(cadr dim)
  dimpt2	(cdr (assoc 10 dimdxf)) ;group code for end of ext line. there is no group code for begining of ext line
  dist		(distance dimpt dimpt2) ;distance to end of dimension line
  )
   (if
     (> dist (/ (cdr (assoc 42 dimdxf)) 2))	;if dist is greater than half the distance you are closer to the begining
     (progn					;modify toward begining of dimension
(vlax-put-property dimobj 'Extline1Suppress :vlax-true)
(vlax-put-property dimobj 'Arrowhead1Block "_ClosedFilled2x")
(vlax-put-property dimobj 'Extline2Suppress :vlax-false)
(vlax-put-property dimobj 'Arrowhead2Block "_Oblique")
(if
  (= *ExtLtype "Center2")
  (vlax-put-property dimobj 'ExtLine2Linetype "CENTER2")
  (vlax-put-property dimobj 'ExtLine2Linetype "ByBlock")
  )
)
     (progn					;modify toward end of demension line
(vlax-put-property dimobj 'Extline2Suppress :vlax-true)
(vlax-put-property dimobj 'Arrowhead2Block "_ClosedFilled2x")
(vlax-put-property dimobj 'Extline1Suppress :vlax-false)
(vlax-put-property dimobj 'Arrowhead1Block "_Oblique")
(if
  (= *ExtLtype "Center2")
  (vlax-put-property dimobj 'ExtLine1Linetype "CENTER2")
  (vlax-put-property dimobj 'ExtLine1Linetype "ByBlock")
  )
);end progn
     );end if
   (vlax-put-property dimobj 'TextOverride "REF DIM. SEE PLAN")
   );end while
 
 (setvar 'Osmode #Osmode)

 (princ)

 )

 

Thanks guys for your suggestions.

Link to comment
Share on other sites

Though I'd check in. You were rigt Tharwat, it does appear to be more reliable using the end of the dimension line.

 

Thanks guys for your suggestions.

 

Good to know. Happy coding. :)

Link to comment
Share on other sites

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