Jump to content

# Lisp divide dimension

## Recommended Posts

Please help me divide dimension, i post drawing before and result. Thank so much.

##### Share on other sites

If you look at the properties of a dimension via entget.

`((-1 . <Entity name: 68b1a340>) (0 . "DIMENSION") (5 . "1A1C") (330 . <Entity name: 68b0fe80>) (100 . "AcDbEntity") (67 . 0) (410 . "Model") (8 . "0") (370 . -1) (100 . "AcDbDimension") (280 . 0) (2 . "*D13") (10 905.565830296284 -1983.72335023666 0.0) (11 -1094.43416970372 -1946.22335023666 0.0) (12 0.0 0.0 0.0) (70 . 32) (1 . "") (71 . 5) (72 . 1) (41 . 1.0) (42 . 4000.0) (73 . 0) (74 . 0) (75 . 0) (52 . 0.0) (53 . 0.0) (54 . 0.0) (51 . 0.0) (210 0.0 0.0 1.0) (3 . "B  1_20 [cm]") (100 . "AcDbAlignedDimension") (13 -3094.43416970372 -2176.25632836718 0.0) (14 905.565830296284 -2176.25632836718 0.0) (15 0.0 0.0 0.0) (16 0.0 0.0 0.0) (40 . 0.0) (50 . 0.0) (100 . "AcDbRotatedDimension"))`

So look at dxf codes 13 & 14 that should be the 2 dim points so get the length divide by say 3. Dxf 10 can be used for offset point. Work out new points erase old dim and make new ones.

Do you know how to program in lisp ? If not good time to learn.

##### Share on other sites

On 9/16/2023 at 10:45 AM, BIGAL said:

If you look at the properties of a dimension via entget.

`((-1 . <Entity name: 68b1a340>) (0 . "DIMENSION") (5 . "1A1C") (330 . <Entity name: 68b0fe80>) (100 . "AcDbEntity") (67 . 0) (410 . "Model") (8 . "0") (370 . -1) (100 . "AcDbDimension") (280 . 0) (2 . "*D13") (10 905.565830296284 -1983.72335023666 0.0) (11 -1094.43416970372 -1946.22335023666 0.0) (12 0.0 0.0 0.0) (70 . 32) (1 . "") (71 . 5) (72 . 1) (41 . 1.0) (42 . 4000.0) (73 . 0) (74 . 0) (75 . 0) (52 . 0.0) (53 . 0.0) (54 . 0.0) (51 . 0.0) (210 0.0 0.0 1.0) (3 . "B  1_20 [cm]") (100 . "AcDbAlignedDimension") (13 -3094.43416970372 -2176.25632836718 0.0) (14 905.565830296284 -2176.25632836718 0.0) (15 0.0 0.0 0.0) (16 0.0 0.0 0.0) (40 . 0.0) (50 . 0.0) (100 . "AcDbRotatedDimension"))`

So look at dxf codes 13 & 14 that should be the 2 dim points so get the length divide by say 3. Dxf 10 can be used for offset point. Work out new points erase old dim and make new ones.

Do you know how to program in lisp ? If not good time to learn.

sorry man. I don't know anything about Lisp programming :((

##### Share on other sites

Getting someone to code for you for free is like an American trying to get service in France. Go in speaking English and they will ignore you, honestly try and speak French and they'd rather reply to you in English than listen to you torture the language.

Try and write your own code and post when you're having problems. Then you're almost guaranteed to get help.

##### Share on other sites

A freebie for you try this

```(defun c:dimdiv ( / ent num pt1 pt2 pt3 pt4)

(setq ent (entget (car (entsel "\nPick dimension "))))
(setq num (getint "\nEnter how many divisons "))

(setq pt1 (cdr (assoc 13 ent)))
(setq pt2 (cdr (assoc 14 ent)))
(setq pt3 (cdr (assoc 10 ent)))
(setq dist (/ (distance pt1 pt2) num))
(setq ang (angle pt1 pt2))

(command "erase" (cdr (assoc -1 ent)) "")

(repeat num
(setq pt4 (polar pt1 ang dist))
(command "DIM" "align" pt1 pt4 pt3 "" "exit")
(setq pt1 pt4)
)

(princ)
)```

##### Share on other sites

10 hours ago, BIGAL said:

A freebie for you try this

```(defun c:dimdiv ( / ent num pt1 pt2 pt3 pt4)

(setq ent (entget (car (entsel "\nPick dimension "))))
(setq num (getint "\nEnter how many divisons "))

(setq pt1 (cdr (assoc 13 ent)))
(setq pt2 (cdr (assoc 14 ent)))
(setq pt3 (cdr (assoc 10 ent)))
(setq dist (/ (distance pt1 pt2) num))
(setq ang (angle pt1 pt2))

(command "erase" (cdr (assoc -1 ent)) "")

(repeat num
(setq pt4 (polar pt1 ang dist))
(command "DIM" "align" pt1 pt4 pt3 "" "exit")
(setq pt1 pt4)
)

(princ)
)```

its not dividing dimension into equal parts, please check the drawing. Thank so much man.

##### Share on other sites

No idea its working for me 3 4 5.

Can some one else please check.

Edited by BIGAL
##### Share on other sites

2 hours ago, BIGAL said:

Can some one else please check.

```(defun c:dimdiv ( / *error* acdoc oldosmode oldcmdecho ent entlist num pt1 pt2 pt3 pt4 entl objl measurevalue digits rounddownvalue lsf ssl index )
(vl-load-com)
(setq acdoc (vla-get-ActiveDocument (vlax-get-acad-object)))
(defun *error* ( msg )
(if (not (wcmatch (strcase msg t) "*break,*cancel*,*exit*"))
(princ (strcat "\nError: " msg))
)
(setvar 'osmode oldosmode)
(setvar 'cmdecho oldcmdecho)
(vla-EndUndoMark acdoc)
(princ)
)
;; Round Down  -  Lee Mac
;; Rounds 'n' down to the nearest 'm'
(defun LM:rounddown (n m)
((lambda (r) (cond ((equal 0.0 r 1e-8) n) ((< n 0) (- n r m)) ((- n r))))
(rem n m)
)
)

(vla-StartUndoMark acdoc)
(setq oldosmode (getvar 'osmode))
(setq oldcmdecho (getvar 'cmdecho))
(setvar 'cmdecho 0)
(setvar 'osmode 0)

(princ "\n Pick Dimension : ")
(if (setq ss (ssget '((0 . "DIMENSION"))))
(progn
(setq num (getint "\nEnter how many divisons "))
(setq ssl (sslength ss))
(setq index 0)
(repeat ssl
(setq ent (ssname ss index))
(setq entlist (entget ent))
(setq pt1 (cdr (assoc 13 entlist)))
(setq pt2 (cdr (assoc 14 entlist)))
(setq pt3 (cdr (assoc 10 entlist)))
(setq dist (/ (distance pt1 pt2) num))
(setq ang (angle pt1 pt2))
(setq lsf (vlax-get-property (vlax-ename->vla-object ent) 'linearscalefactor))
(entdel ent)
(repeat num
(setq pt4 (polar pt1 ang dist))
(command "DIM" "align" pt1 pt4 pt3 "" "exit")
(setq entl (entlast))
(setq objl (vlax-ename->vla-object entl))
(vlax-put-property objl 'linearscalefactor lsf)
(setq measurevalue (vlax-get-property objl 'measurement))
(setq digits (strlen (rtos measurevalue 2 0)))
(setq rounddownvalue (LM:rounddown measurevalue (expt 10 (- digits 2))))
(vlax-put-property objl 'textoverride rounddownvalue)
(setq pt1 pt4)
)
(setq index (+ index 1))
)
)
(progn)
)
(setvar 'osmode oldosmode)
(setvar 'cmdecho oldcmdecho)
(vla-EndUndoMark acdoc)
(princ)
)```

maybe osmode do that?

Edited by exceed

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

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