Kvlar Posted May 23 Posted May 23 I found Autolisp code with a function to adjust the Dimension Line Extension to a certain length (adjusted by determining the length point of the Dimension Line Extension). The problem is, this code can only be used on horizontal dimensions and cannot be used on vertical dimensions or aligned dimensions. Can anyone help me with this problem? Thank You I attached the code that I found on the Autocad forum and I attached the Autocad file that I am working on D2.lsp AutoCAD Files.dwg Quote
Kvlar Posted May 23 Author Posted May 23 This is the code I got on the forum : (defun C:D2 (/ 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")))) (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) ) Quote
CyberAngel Posted May 23 Posted May 23 You'll need to know what DXF codes mean and how to change them in an AutoCAD entity. Also, it helps to make the code more readable if you indent. If you need more help than that, I'm sure someone can rewrite it for you. Quote
Kvlar Posted May 23 Author Posted May 23 1 minute ago, CyberAngel said: Anda harus mengetahui apa arti kode DXF dan bagaimana mengubahnya di entitas AutoCAD. Selain itu, ini membantu membuat kode lebih mudah dibaca jika Anda membuat indentasi. Jika Anda memerlukan bantuan lebih dari itu, saya yakin seseorang dapat menulis ulang untuk Anda. Yeah, I hope someone can help me Quote
pkenewell Posted May 23 Posted May 23 Try this modification of your code - minimally tested, but I am exploiting using inters and polar to work with linear, rotated, or aligned dimensions at any angle. Doesn't do anything on any other type of dimension. (defun C:D2 (/ 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")))) (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)))) dtyp (cdr (assoc 70 ds)) ) (cond ((member dtyp (list 32 160))(setq ang (cdr (assoc 50 ds)))) ((member dtyp (list 33 161))(setq ang (angle (cdr (assoc 13 ds)) (cdr (assoc 14 ds))))) ) (if ang (progn (setq n13 (inters (cdr (assoc 13 ds)) (polar (cdr (assoc 13 ds)) (+ ang (/ pi 2)) 1) pt (polar pt ang 1) nil ) ds (subst (cons 13 n13) (assoc 13 ds) ds) n14 (inters (cdr (assoc 14 ds)) (polar (cdr (assoc 14 ds)) (+ ang (/ pi 2)) 1) pt (polar pt ang 1) nil ) ds (subst (cons 14 n14) (assoc 14 ds) ds) ) (entmod ds) ) ) ) (command "UCS" "_P") (setvar "CMDECHO" cmd) (setvar "OSMODE" osm) (setq *error* olderr) (princ) ) 1 Quote
Kvlar Posted May 23 Author Posted May 23 8 minutes ago, pkenewell said: Try this modification of your code - minimally tested, but I am exploiting using inters and polar to work with linear, rotated, or aligned dimensions at any angle. Doesn't do anything on any other type of dimension. (defun C:D2 (/ 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")))) (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)))) dtyp (cdr (assoc 70 ds)) ) (cond ((member dtyp (list 32 160))(setq ang (cdr (assoc 50 ds)))) ((member dtyp (list 33 161))(setq ang (angle (cdr (assoc 13 ds)) (cdr (assoc 14 ds))))) ) (if ang (progn (setq n13 (inters (cdr (assoc 13 ds)) (polar (cdr (assoc 13 ds)) (+ ang (/ pi 2)) 1) pt (polar pt ang 1) nil ) ds (subst (cons 13 n13) (assoc 13 ds) ds) n14 (inters (cdr (assoc 14 ds)) (polar (cdr (assoc 14 ds)) (+ ang (/ pi 2)) 1) pt (polar pt ang 1) nil ) ds (subst (cons 14 n14) (assoc 14 ds) ds) ) (entmod ds) ) ) ) (command "UCS" "_P") (setvar "CMDECHO" cmd) (setvar "OSMODE" osm) (setq *error* olderr) (princ) ) Thank you very much for your help. This is exactly what I needed. I will learn from the code you modified 1 Quote
Recommended Posts
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.