Jump to content

[Solved] Lisp to move all point of dimension to dimension's line.


haisagiviz

Recommended Posts

Hello everyone,

 

Please help me a lisp to move all points of dimension to each of dimension line of them.

 

Thank you very much,

Regards,

03.jpg

Link to comment
Share on other sites

Are you kidding me?? ^.^

I just want to do it by Autolisp not Photoshop skill ^^

Btw your pts skill is so well :)

Thanks.

Link to comment
Share on other sites

Here is a solution for AcDbAlignedDimension and AcDbRotatedDimension objects (adapted version of code published here).

(vl-load-com)

(defun KGA_Conv_Pickset_To_EnameList (ss / i ret)
  (if ss
    (repeat (setq i (sslength ss))
      (setq ret (cons (ssname ss (setq i (1- i))) ret))
    )
  )
)

(defun KGA_List_LastRemove (lst)
  (reverse (cdr (reverse lst)))
)

; (PutDefPointsOnDimLine (car (entsel)))
(defun PutDefPointsOnDimLine (enm / ang elst nor pt0 pt1 pt2)
  (setq elst (entget enm))
  (if (vl-position '(100 . "AcDbAlignedDimension") elst)
    (progn
      (setq nor (cdr (assoc 210 elst)))
      (setq pt0 (trans (cdr (assoc 10 elst)) 0 nor))
      (setq pt1 (append (KGA_List_LastRemove (trans (cdr (assoc 13 elst)) 0 nor)) (cddr pt0)))
      (setq pt2 (append (KGA_List_LastRemove (trans (cdr (assoc 14 elst)) 0 nor)) (cddr pt0)))
      (setq ang
        (if (vl-position '(100 . "AcDbRotatedDimension") elst)
          (cdr (assoc 50 elst))
          (angle pt1 pt2)
        )
      )
      ;; For Rotated Dimensions gc 13 and gc 14 must be changed together.
      (entmod
        (subst
          (cons 13 (trans (inters pt0 (polar pt0 ang 1.0) pt1 (polar pt1 (+ ang (* 0.5 pi)) 1.0) nil) nor 0))
          (assoc 13 elst)
          (subst
            (cons 14 (trans (inters pt0 (polar pt0 ang 1.0) pt2 (polar pt2 (+ ang (* 0.5 pi)) 1.0) nil) nor 0))
            (assoc 14 elst)
            elst
          )
        )
      )
      T
    )
  )
)

(defun c:Test ( / doc ss)
  (setq doc (vla-get-activedocument (vlax-get-acad-object)))
  (vla-endundomark doc)
  (vla-startundomark doc)
  (if (setq ss (ssget '((100 . "AcDbAlignedDimension"))))
    (progn
      (setvar 'cmdecho 0)
      (command "_.dimdisassociate" ss "")
      (setvar 'cmdecho 1)
      (mapcar 'PutDefPointsOnDimLine (KGA_Conv_Pickset_To_EnameList ss))
    )
  )
  (vla-endundomark doc)
  (princ)
)

 

Edited by Roy_043
Added (vl-load-com)
Link to comment
Share on other sites

19 minutes ago, Roy_043 said:

Here is a solution for AcDbAlignedDimension and AcDbRotatedDimension objects (adapted version of code published here).

Hi Roy,

 

Thank you so much for your help,

But it is not working for me. Please confirm by attach image file.

Regards,

01.jpg

Link to comment
Share on other sites

I have added (vl-load-com) to the code in my previous post. This is required for AutoCAD, but not for BricsCAD (which I use). Hopefully this will fix your issue.

Link to comment
Share on other sites

43 minutes ago, Roy_043 said:

I have added (vl-load-com) to the code in my previous post. This is required for AutoCAD, but not for BricsCAD (which I use). Hopefully this will fix your issue.

I just try to load vl-load-com but sorry I cannot understand how to load it. Can you explain to me how to load it? I'm using AutoCAD 2019.

I'm just using Lisp but not yet made any Lisp myself before. I want to learn how to create Lisp for more performance my workflow.

Thanks again.

11.jpg

12.jpg

Link to comment
Share on other sites

@Roy_043 you are amazing! It was working for me.

But my Dim have a little problem because I exported the DWG drawing from BIM software (ArchiCAD) and the dimension have a issue need to solve as attached image.

BTW it worked as I expected, so thank you very much. I will learn from your lisp.

Regards.

14.jpg

15.jpg

Link to comment
Share on other sites

Hi @Roy_043

I can solve it by first change to standard dim style and do the Lisp to solve it. I work for me. Thanks

 

P/S: Could you please add to first of lisp.

Step 1. Select all of dims with conditions like as 

       - "Ext line 1 or 2" property is Off status.

or   - By layer

or   - Selection set by mouse

--> I know this request is difficult but it is my big issue for now. Because I don't know how to create lisp with selection dimension with variable conditions like Dimension properties, layer or something like that. I want to learn. BTW thanks very much for your kind.

 

Step 2.  Do PutDefPointsOn.lisp to bring dim point to base line (the lisp worked for now)

 

Thank you so so much.

16.jpg

Link to comment
Share on other sites

  • haisagiviz changed the title to [Solved] Lisp to move all point of dimension to dimension's line.
  • 2 weeks later...

Hi @Roy_043
Could you please help me another request of above lisp?
I am looking for a lisp can turn off or move dim point (as your lisp routine above) of the extension line of dimension when overlap other line or polyline object.

 

I want to use ssget to make the selection set before do the lisp routine.

 

Thank for your help.

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