Jump to content

Dimension's extension line jumping with lisp


vuxvix

Recommended Posts

Hi !

I have 2 problems when using the Dim edit lisp
1. I'm using this lisp to edit dim extension line. when working with dims without extension lines, it will cause dim to jump and change values. Is there any way to fix this problem of lisp(image attached and lisp "Dim Edit").

 

2. I searched but didn't find any topic about selecting linear dims (like how to create dim continue) horizontally, vertically or even diagonally. Is there any solution.
Ps: I use this macro for select vertical dimension:
^C^C(sssetfirst nil (ssget (list '(0 . "DIMENSION") '(-4 . "&=") '(70 . 0) (cons 50 (* pi 0.5)))));Dim Edit.Lsp
Appreciate any help.

Dim.JPG

DIM 2.jpg

Sample.dwg

Link to comment
Share on other sites

Problem one:

(defun C:VV1 (/ cmd osm olderr ss PT index DS N13 N14)
 (setq cmd (getvar "CMDECHO")
       osm (getvar "OSMODE")
       olderr *error* *error* myerror
 )
 (princ "Please select dimension object!")
 (setq ss (ssget '((0 . "DIMENSION"))))
 (setvar "CMDECHO" 0)
 (setq PT (getpoint "\nPoint to trim or extend:")
       PT (trans PT 1 0)
 )
 (command "UCS" "_W")
 (repeat (setq index (sslength ss))
  (setq DS (entget (ssname ss (setq index (1- index)))))
  (cond
   ((equal (cdr (assoc 50 DS)) 0.0 0.001)
    (setq N13 (cons 13 (list (car (cdr (assoc 13 DS))) (cadr PT) (caddr (cdr (assoc 13 DS)))))
          DS (subst N13 (assoc 13 DS) DS)
          N14 (cons 14 (list (car (cdr (assoc 14 DS))) (cadr PT) (caddr (cdr (assoc 14 DS)))))
          DS (subst N14 (assoc 14 DS) DS)
    )	 
    (entmod DS)
   )
   ((equal (cdr (assoc 50 DS)) (/ pi 2) 0.001)
    (setq N13 (cons 13 (list (car PT) (cadr (cdr (assoc 13 DS))) (caddr (cdr (assoc 13 DS)))))
          DS (subst N13 (assoc 13 DS) DS)
          N14 (cons 14 (list (car PT) (cadr (cdr (assoc 14 DS))) (caddr (cdr (assoc 14 DS)))))
          DS (subst N14 (assoc 14 DS) DS)
    )
    (entmod DS)
   )
  )
 )
 (command "UCS" "_P")
 (setvar "CMDECHO" cmd)
 (setvar "OSMODE" osm)
 (setq *error* olderr)
 (princ)
)

 

Problem two:

;;; select horizontal and vertical dimension
(setq ss (ssget	(list (cons 0 "DIMENSION")
		      (cons -4 "<OR")
		       (cons 50 0.0)
		       (cons 50 (/ pi 2))
		      (cons -4 "OR>")
	        )
	)
)

(repeat (setq index (sslength ss))
 (if (not (equal (last (entget (ssname ss (setq index (1- index))))) '(100 . "AcDbRotatedDimension")))
  (ssdel (ssname ss index) ss)
 )
)

 

Edited by confutatis
  • Like 1
  • Thanks 1
Link to comment
Share on other sites

9 hours ago, confutatis said:

Problem one:


(defun C:VV1 (/ cmd osm olderr ss PT index DS N13 N14)
 (setq cmd (getvar "CMDECHO")
       osm (getvar "OSMODE")
       olderr *error* *error* myerror
 )
 (princ "Please select dimension object!")
 (setq ss (ssget '((0 . "DIMENSION"))))
 (setvar "CMDECHO" 0)
 (setq PT (getpoint "\nPoint to trim or extend:")
       PT (trans PT 1 0)
 )
 (command "UCS" "_W")
 (repeat (setq index (sslength ss))
  (setq DS (entget (ssname ss (setq index (1- index)))))
  (cond
   ((equal (cdr (assoc 50 DS)) 0.0 0.001)
    (setq N13 (cons 13 (list (car (cdr (assoc 13 DS))) (cadr PT) (caddr (cdr (assoc 13 DS)))))
          DS (subst N13 (assoc 13 DS) DS)
          N14 (cons 14 (list (car (cdr (assoc 14 DS))) (cadr PT) (caddr (cdr (assoc 14 DS)))))
          DS (subst N14 (assoc 14 DS) DS)
    )	 
    (entmod DS)
   )
   ((equal (cdr (assoc 50 DS)) (/ pi 2) 0.001)
    (setq N13 (cons 13 (list (car PT) (cadr (cdr (assoc 13 DS))) (caddr (cdr (assoc 13 DS)))))
          DS (subst N13 (assoc 13 DS) DS)
          N14 (cons 14 (list (car PT) (cadr (cdr (assoc 14 DS))) (caddr (cdr (assoc 14 DS)))))
          DS (subst N14 (assoc 14 DS) DS)
    )
    (entmod DS)
   )
  )
 )
 (command "UCS" "_P")
 (setvar "CMDECHO" cmd)
 (setvar "OSMODE" osm)
 (setq *error* olderr)
 (princ)
)

 

Problem two:


(setq ss (ssget '((0 . "DIMENSION")(50 . 0.0))));;; select horizontal dimension
(setq ss (ssget (list (cons 0 "DIMENSION")(cons 50 (/ pi 2)))));;; select vertical dimension

 

Thank you very much. I tried it and it works correctly. If possible, I hope to invite you to donate a cup of coffe 🙂
Forgive me, I have 2 unfulfilled points:
1. In the file Dim Edit.Lsp: also include lisp " stretch" Dim via select and pick point. I noticed it has the same problem and structure as Lisp "Extension Line". I tried fixing it, but unfortunately it doesn't work.
2. I don't know how to write lisp from the line of code you provided (Dim Hor-Ver selection). If you can provide lisp file or instructions to create lisp. That will help me a lot.

Link to comment
Share on other sites

I have corrected my post above, I realised that before it also selected aligned dimensions that resulted in a 0° angle. Now it selects rotated dimensions with a rotation angle of 0° or 90°, because horizontal and vertical dimensions are special types of rotated dimensions.

  • Confused 1
Link to comment
Share on other sites

Thank you. What do I need to do for this code to work. Can you help me edit it?

Quote

(defun C:test ()
(setq ss (ssget    (list (cons 0 "DIMENSION")
              (cons -4 "<OR")
               (cons 50 0.0)
               (cons 50 (/ pi 2))
              (cons -4 "OR>")
            )
    )
)

(repeat (setq index (sslength ss))
 (if (not (equal (last (entget (ssname ss (setq index (1- index))))) '(100 . "AcDbRotatedDimension")))
  (ssdel (ssname ss index) ss)
 )
)
 

 

Link to comment
Share on other sites

You are right, here is the version of VV1 with the new selection:

(defun C:VV1 (/ cmd osm olderr ss PT index DS N13 N14)
 (setq cmd (getvar "CMDECHO")
       osm (getvar "OSMODE")
       olderr *error* *error* myerror
 )
 (princ "Please select dimension object!")
 (setq ss (ssget (list (cons 0 "DIMENSION") (cons -4 "<OR") (cons 50 0.0) (cons 50 (/ pi 2)) (cons -4 "OR>"))))
 (repeat (setq index (sslength ss))
  (if (not (equal (last (entget (ssname ss (setq index (1- index))))) '(100 . "AcDbRotatedDimension")))
   (ssdel (ssname ss index) ss)
  )
 ) 
 (setvar "CMDECHO" 0)
 (setq PT (getpoint "\nPoint to trim or extend:")
       PT (trans PT 1 0)
 )
 (command "UCS" "_W")
 (repeat (setq index (sslength ss))
  (setq DS (entget (ssname ss (setq index (1- index)))))
  (cond
   ((equal (cdr (assoc 50 DS)) 0.0 0.001)
    (setq N13 (cons 13 (list (car (cdr (assoc 13 DS))) (cadr PT) (caddr (cdr (assoc 13 DS)))))
          DS (subst N13 (assoc 13 DS) DS)
          N14 (cons 14 (list (car (cdr (assoc 14 DS))) (cadr PT) (caddr (cdr (assoc 14 DS)))))
          DS (subst N14 (assoc 14 DS) DS)
    )	 
    (entmod DS)
   )
   ((equal (cdr (assoc 50 DS)) (/ pi 2) 0.001)
    (setq N13 (cons 13 (list (car PT) (cadr (cdr (assoc 13 DS))) (caddr (cdr (assoc 13 DS)))))
          DS (subst N13 (assoc 13 DS) DS)
          N14 (cons 14 (list (car PT) (cadr (cdr (assoc 14 DS))) (caddr (cdr (assoc 14 DS)))))
          DS (subst N14 (assoc 14 DS) DS)
    )
    (entmod DS)
   )
  )
 )
 (command "UCS" "_P")
 (setvar "CMDECHO" cmd)
 (setvar "OSMODE" osm)
 (setq *error* olderr)
 (princ)
)

 

Edited by confutatis
  • Like 1
Link to comment
Share on other sites

Hi Confutatis !

Perhaps you took it the other way around what I meant at the beginning. Point 2: in the topic is another lisp, I just want to quickly select linear dims (horizontal, vertical, diagonal...).
But your way it helps lisp extension Dim more complete.
I tried to test it, but how to control the selection in the desired direction. Is it possible to add an option to specify the orientation before editing the extension line?

Thanks

Link to comment
Share on other sites

Excuse me, but I don't think I understand. The selection in the program selects the horizontal and vertical dimensions. If you also want to select diagonals, what angle of rotation do they have to be? Can I have diagonals at 30°, 45°, 60°, etc.?

Link to comment
Share on other sites

Sorry for taking up so much of your time. English is not my native language.

I will try to explain with Attachment.

Example: Slope park ramp- it has no specific angle. Maybe I shouldn't have mentioned the diagonal in the description. Instead I want to select Dims that are on the same route (just like creat dimension using the Dim continue command).

Can you separate this Lisp from the "Extension line" Lisp? Because choosing dim also helps me perform other editing operations.

Looking forward to your help.Thanks

P/s: I also attached a lisp which helps me to resize the Extension line by entering the value. It also has problems with Dims that don't have an Extension line.

 

Sample Select.dwg KK-ExtlineDimension.lsp

Edited by vuxvix
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...