Jump to content

Lisp to change extension line to center


Grigs

Recommended Posts

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.

Link to comment
Share on other sites

(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
Link to comment
Share on other sites

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 .

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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 ?

Link to comment
Share on other sites

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