Jump to content

Recommended Posts

Posted

Does anyone have to know of a lisp routine that will allow someone to pick an extension line and change it to CENTER?

Posted

Does it mean that you want to reduce the length of a line to its center point ?

Posted

No, I want to be able to pick one of the extension lines and change it to CENTER type. Ideally, it would be nice to have the option to change it's LTSCALE as well.

Posted (edited)
(defun c:Foo (/ sel Doc)
 (vl-load-com)
 (setq Doc (vla-get-ActiveDocument (vlax-get-acad-object)))
 (if (and (setq
            sel (car (nentsel "\n Select extension line on dimension :"))
          )
          (eq (cdr (assoc 0 (entget sel))) "LINE")
     )
   (progn
     (if (not (tblsearch "LTYPE" "CENTER"))
       (vla-load (vla-get-Linetypes Doc)
                 "CENTER"
                 "acadiso.lin"
       )
     )

     (vla-put-Linetype (vlax-ename->vla-object sel) "CENTER")
     (vla-regen Doc AcAllViewports)
   )
 )
 (princ)
)

Edited by Tharwat
Posted

That works on regular entities but not dimension extension lines

Posted
that works on regular entities but not dimension extension lines

 

codes updated above .

Posted

That works. Is there a way to only change the extension line that was picked?

Posted

Close. But it doesn't change the extension line.

Posted
Close. But it doesn't change the extension line.

 

What kind of extension line you are talking about ?

Posted

Either the left or right extension line in a dimension.

Posted

It will change a regular line to Center but not the extension line of a linear dimension, which I am trying to achieve.

Posted
It will change a regular line to Center but not the extension line of a linear dimension, which I am trying to achieve.

 

That's not correct , upload a sample drawing and indicate to the extension line that you're talking about in the drawing .

Posted

The code does the trick as needed but the issue is with the line type scale , so I added one line of code to scale all extension lines with the same value , and after that you can play with the ltscale and it would change all of them with the same gap distance .

 

(defun c:Foo (/ sel Doc)
 (vl-load-com)
 (setq Doc (vla-get-ActiveDocument (vlax-get-acad-object)))
 (if (and (setq
            sel (car (nentsel "\n Select extension line on dimension :"))
          )
          (eq (cdr (assoc 0 (entget sel))) "LINE")
     )
   (progn
     (if (not (tblsearch "LTYPE" "CENTER"))
       (vla-load (vla-get-Linetypes Doc)
                 "CENTER"
                 "acadiso.lin"
       )
     )

     (vla-put-Linetype (vlax-ename->vla-object sel) "CENTER")
     (vla-put-Linetypescale (vlax-ename->vla-object sel) 1.0)
     (vla-regen Doc AcAllViewports)
   )
 )
 (princ)
)

Posted

Odd. When I run the routine and pick an extension line and then look at the properties of it, nothing has changed. The linetype of the extension line is still ByLayer and the LTScale is still 1

Posted
Odd. When I run the routine and pick an extension line and then look at the properties of it, nothing has changed. The linetype of the extension line is still ByLayer and the LTScale is still 1

 

Really odd , check the Line Type Control , the "LTYPE" Table - do you have the Center ltype property in that table after running the code ?

Posted

Yeah, I have the necessary linetypes loaded in the drawing.

Posted (edited)

Try this:

(defun c:extlt ( / ent enx ltp obj pnt )
   (setq ltp "CENTER")
   (if (tblsearch "LTYPE" ltp)
       (progn
           (while
               (progn (setvar 'errno 0) (setq ent (entsel "\nSelect Extension Line: "))
                   (cond
                       (   (= 7 (getvar 'errno))
                           (princ "\nMissed, try again.")
                       )
                       (   (null ent) nil)
                       (   (not (wcmatch (cdr (assoc 0 (entget (car ent)))) "*DIMENSION"))
                           (princ "\nSelected object is not a Dimension: ")
                       )
                   )
               )
           )
           (if ent
               (progn
                   (setq pnt (trans (cadr ent) 1 0)
                         enx (entget (car ent))
                         obj (vlax-ename->vla-object (car ent))
                   )
                   (vlax-put-property obj
                       (if (< (distance pnt (cdr (assoc 13 enx))) (distance pnt (cdr (assoc 14 enx))))
                           'extline1linetype
                           'extline2linetype
                       )
                       ltp
                   )
               )
           )                            
       )
       (princ (strcat "\nLinetype " ltp " not loaded."))
   )
   (princ)
)
(vl-load-com) (princ)
 
Edited by Lee Mac

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