PDA

View Full Version : Routine for spliting a dimension.



jgardner.79905
2005-10-25, 02:41 PM
I was hoping someone would know a routine for splitting one dimension into two dimensions. The idea would be for the user to first select the dimension to be split, then pick a point for the new node location of the two dimensions between the two original nodes of the original dimension. Anyone have any script ideas for this.

If possible any suggestions or scripting help for combining two dims into one would also be really great.

Thanks!

Jason

T.Willey
2005-10-25, 04:04 PM
Here is a quick little dirty idea. No error checking.


(defun c:DivideDim (/ Sel EntData Pt NewDim1 NewDim2)

(if
(and
(setq Sel (entsel "\n Select dimension: "))
(setq EntData (entget (car Sel)))
(setq Pt (getpoint "\n Select point: "))
)
(progn
(setq NewDim1 (subst (cons 13 Pt) (assoc 13 EntData) EntData))
(setq NewDim2 (subst (cons 14 Pt) (assoc 14 EntData) EntData))
(entdel (car Sel))
(entmake NewDim1)
(entmake NewDim2)
)
)
(princ)
)

Tim

T.Willey
2005-10-25, 04:05 PM
The happy face should be ": D" without the space.

Tim

Glenn Pope
2005-10-25, 04:18 PM
The happy face should be ": D" without the space.

Tim
Hi Tim

Placing your code in code tags will remove smilies from your code. I have modified you post, and added the tags.

Check out vB Code List (http://forums.augi.com/misc.php?do=bbcode#code)

T.Willey
2005-10-25, 04:35 PM
Thanks. I will check out the link.

jgardner.79905
2005-10-25, 04:40 PM
That works great thanks!!! Any ideas on how to merge two dims?

Jason

T.Willey
2005-10-25, 05:22 PM
Try this.


(defun c:MergeDims (/ Sel EntData PtList Ent1 Ent2 tmpList EndList NewDim)

(if
(and
(setq Sel (entsel "\n Select firs dimension: "))
(setq EntData (entget (car Sel)))
(setq PtList (cons (cdr (assoc 13 EntData)) PtList))
(setq PtList (cons (cdr (assoc 14 EntData)) PtList))
(setq Ent1 (car Sel))
(setq Sel (entsel "\n Select second dimension: "))
(setq EntData (entget (car Sel)))
(setq PtList (cons (cdr (assoc 13 EntData)) PtList))
(setq PtList (cons (cdr (assoc 14 EntData)) PtList))
(setq Ent2 (car Sel))
)
(progn
(foreach Pt PtList
(setq tmpList (mapcar '(lambda (x) (list (distance Pt x) (list Pt x))) PtList))
(setq tmpList (vl-sort tmpList '(lambda (a b) (> (car a) (car b)))))
(setq EndList (cons (car tmpList) EndList))
)
(setq EndList (vl-sort EndList '(lambda (a b) (> (car a) (car b)))))
(setq tmpList (cadar EndList))
(setq NewDim (subst (cons 13 (car tmpList)) (assoc 13 EntData) EntData))
(setq NewDim (subst (cons 14 (cadr tmpList)) (assoc 14 NewDim) NewDim))
(entmake NewDim)
(entdel Ent1)
(entdel Ent2)
)
)
(princ)
)

fixo
2005-10-25, 07:37 PM
That works great thanks!!! Any ideas on how to merge two dims?

Jason

Hi Jason

Quick and dirty, but maybe this will work for you

Thank you

f.



(prompt "\n\t***\tType SPD to run program\t***\n")
(defun C:spd ()
(if (not cal)
(arxload "geomcal"))
(setq dim_en (car (entsel "\nSelect dimension\n")))

(setq elist (entget dim_en)
st_pt (cdr (assoc 13 elist))
en_pt (cdr (assoc 14 elist))
dm_pt (cdr (assoc 10 elist))
)
(setvar "osmode" 675)
(initget 1)
(setq nw_pt (osnap (getpoint "\nPick point for new node location \n") "_nea"))
(setq factor (/ (- (distance st_pt en_pt)(distance dm_pt nw_pt))(distance st_pt en_pt)
))
(setvar "osmode" 0)
(setq mp_pt (cal "plt (st_pt,en_pt,factor)"))
(command "copy" dim_en "" st_pt st_pt)
(setq dim1 (entlast))
(setq elist1 (entget dim1)
elist1 (subst (cons 14 mp_pt)(assoc 14 elist1) elist1))
(entmod elist1)
(entupd dim1)
(command "copy" dim_en "" st_pt st_pt)
(setq dim2 (entlast))
(setq elist2 (entget dim2)
elist2 (subst (cons 13 mp_pt)(assoc 13 elist2) elist2)
)
(entmod elist2)
(entupd dim2)
(command "erase" dim_en "")
(princ)
)

Sorry
I found some errors in my routine and now I had edited it
28 oct 2005

jgardner.79905
2005-10-25, 08:23 PM
Every-things working great thanks a lot everyone!