Author Topic: Spltting Dimensions  (Read 4333 times)

0 Members and 1 Guest are viewing this topic.

MSTG007

  • Gator
  • Posts: 2606
  • I can't remeber what I already asked! I need help!
Spltting Dimensions
« on: May 23, 2016, 04:19:55 PM »
I stumbled on to a neat idea for dimensioning up plans. You place an overall dimension line first. Then you come back and pick points on the object and it will break or split that overall dimension line up.

http://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/how-to-divide-dimension-line-in-points/td-p/6226098

Code: [Select]
(defun c:SplitDims (/ sel newpt ent edata elist def1 def2)
(command "_.UCS" "_W")
(if (and (setq sel (entsel "\nSelect Dimension to Split: "))
(setq def1 (cdr (assoc 13 (entget (car sel))))
def2 (cdr (assoc 14 (entget (car sel))))))
(while (setq newpt (getpoint def2 "\nSelect new Dim Point <exit>: "))
(setq newpt (inters def1 def2 newpt (polar newpt (+ (angle def1 def2) (/ pi 2)) 1) nil)
ent (car sel)
edata (entget ent)
elist (vl-remove-if
'(lambda (pair)
(member (car pair)
(list -1 2 5 102 310 300 330 331 340 350 360 410)))
edata))
(entmod (subst (cons 14 newpt) (assoc 14 elist) edata))
(entmakex (subst (cons 13 newpt) (assoc 13 elist) elist))))
(command "_.UCS" "_P")
(princ)
)


The only question I have is. I am using annotative dimensions on plans. When I execute the command, it works but all the new split dimensions come in not annotative. Any ideas on that one?
Civil3D 2020

roy_043

  • Water Moccasin
  • Posts: 1895
  • BricsCAD 18
Re: Spltting Dimensions
« Reply #1 on: May 23, 2016, 05:19:15 PM »
Copying the original dimension and then using entmod may work. But you would still have the problem of the modified dimensions no longer being associative.

Grrr1337

  • Swamp Rat
  • Posts: 812
Re: Spltting Dimensions
« Reply #2 on: May 24, 2016, 04:41:18 AM »
Well, this one is better than the one I currently use, so I tweaked the one you posted:
Code: [Select]
; Split Dims
(defun c:test (/ type ss sel newpt ent edata elist def1 def2 oldSC)

(setvar 'errno 0)
(while
(not
(and
(setq sel (entsel "\nSelect Dimension to Split: "))
(setq def1 (cdr (assoc 14 (entget (car sel)))))
(setq def2 (cdr (assoc 13 (entget (car sel)))))
)
)
(cond
(   (= 7 (getvar 'errno))
(princ "\nYou must select an object.")
)
(   (null sel)
(princ "\nYou missed, try again.")
)
);cond
);while

(progn
(command "_.UCS" "_W")
(setq oldSC (getvar 'SELECTIONCYCLING))
(setvar 'SELECTIONCYCLING -2)
(while
(setq newpt (getpoint def2 "\nSelect new Dim Point <exit>: "))
(setq newpt (inters def1 def2 newpt (polar newpt (+ (angle def1 def2) (/ pi 2)) 1) nil)
ent (car sel)
edata (entget ent)
elist (vl-remove-if
'(lambda (pair)
(member (car pair)
(list -1 2 5 102 310 300 330 331 340 350 360 410)))
edata)
)
(entmod (subst (cons 13 newpt) (assoc 13 elist) edata))
(entmakex (subst (cons 14 newpt) (assoc 14 elist) elist))
)
(command "_.UCS" "_P")
(setvar 'SELECTIONCYCLING oldSC)
);progn

(princ)
)
It does not solve your question, but it will prompt you for entsel until a dimension is picked (and also turns off selectioncycling while picking the split points) - which is more user friendly IMO.
(apply ''((a b c)(a b c))
  '(
    (( f L ) (apply 'strcat (f L)))
    (( L ) (if L (cons (chr (car L)) (f (cdr L)))))
    (72 101 108 108 111 32 87 111 114 108 100)
  )
)
vevo.bg

nobody

  • Swamp Rat
  • Posts: 861
  • .net stuff
Re: Spltting Dimensions
« Reply #3 on: May 24, 2016, 05:07:48 AM »
This is interesting..would cut clicks down considerably I think. Thanks for sharing.

MSTG007

  • Gator
  • Posts: 2606
  • I can't remeber what I already asked! I need help!
Re: Spltting Dimensions
« Reply #4 on: May 24, 2016, 06:59:44 AM »
this is just me with an idea... What about a forum dedicate for less clicks to do things? lol. I know I am lazy too. I need to work on that.
Civil3D 2020

MSTG007

  • Gator
  • Posts: 2606
  • I can't remeber what I already asked! I need help!
Re: Spltting Dimensions
« Reply #5 on: May 24, 2016, 07:08:52 AM »
Well, this one is better than the one I currently use, so I tweaked the one you posted:
Code: [Select]
; Split Dims
(defun c:test (/ type ss sel newpt ent edata elist def1 def2 oldSC)

(setvar 'errno 0)
(while
(not
(and
(setq sel (entsel "\nSelect Dimension to Split: "))
(setq def1 (cdr (assoc 14 (entget (car sel)))))
(setq def2 (cdr (assoc 13 (entget (car sel)))))
)
)
(cond
(   (= 7 (getvar 'errno))
(princ "\nYou must select an object.")
)
(   (null sel)
(princ "\nYou missed, try again.")
)
);cond
);while

(progn
(command "_.UCS" "_W")
(setq oldSC (getvar 'SELECTIONCYCLING))
(setvar 'SELECTIONCYCLING -2)
(while
(setq newpt (getpoint def2 "\nSelect new Dim Point <exit>: "))
(setq newpt (inters def1 def2 newpt (polar newpt (+ (angle def1 def2) (/ pi 2)) 1) nil)
ent (car sel)
edata (entget ent)
elist (vl-remove-if
'(lambda (pair)
(member (car pair)
(list -1 2 5 102 310 300 330 331 340 350 360 410)))
edata)
)
(entmod (subst (cons 13 newpt) (assoc 13 elist) edata))
(entmakex (subst (cons 14 newpt) (assoc 14 elist) elist))
)
(command "_.UCS" "_P")
(setvar 'SELECTIONCYCLING oldSC)
);progn

(princ)
)
It does not solve your question, but it will prompt you for entsel until a dimension is picked (and also turns off selectioncycling while picking the split points) - which is more user friendly IMO.

I got a question. I did find a work around to the annotation issue. Just run the following commands after you get them split up.

-dimstyle;Apply;;

I wonder if that can be incorporated in during each split...
Civil3D 2020


MSTG007

  • Gator
  • Posts: 2606
  • I can't remeber what I already asked! I need help!
Re: Spltting Dimensions
« Reply #7 on: May 24, 2016, 08:58:18 AM »
Good find. It was pretty easy to do that. The only thing I see that you would have to remember is to delete the original overall baseline dimension. The annotative part of the dimension worked great.

I guess its user preference, but something about setting your baseline dimension first then going back and clicking the points where you want the splits to be.
Civil3D 2020

ChrisCarlson

  • Guest
Re: Spltting Dimensions
« Reply #8 on: May 24, 2016, 09:01:28 AM »
Now if only associative dimensions worked as nice in AutoCAD as they do Revit...

ronjonp

  • Needs a day job
  • Posts: 7535
Re: Spltting Dimensions
« Reply #9 on: May 24, 2016, 11:00:33 AM »
this is just me with an idea... What about a forum dedicate for less clicks to do things? lol. I know I am lazy too. I need to work on that.
The forum that does this is called TheSwamp  ;)

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

MSTG007

  • Gator
  • Posts: 2606
  • I can't remeber what I already asked! I need help!
Re: Spltting Dimensions
« Reply #10 on: May 24, 2016, 11:05:10 AM »
aka the best places for ideas too!
Civil3D 2020

kdub_nz

  • Mesozoic keyThumper
  • SuperMod
  • Water Moccasin
  • Posts: 2166
  • class keyThumper<T>:ILazy<T>
Re: Spltting Dimensions
« Reply #11 on: May 25, 2016, 01:36:56 AM »
Called Kerry in my other life
Retired; but they dragged me back in !

I live at UTC + 13.00

---
some people complain about loading the dishwasher.
Sometimes the question is more important than the answer.

Grrr1337

  • Swamp Rat
  • Posts: 812
Re: Spltting Dimensions
« Reply #12 on: May 25, 2016, 04:06:04 AM »

I thought that code looked familiar :)

https://www.theswamp.org/index.php?topic=33493.msg389029#msg389029
This is the one I used, but its kinda annoying as it prompts continiously to select dimension to split.
The one MSTG007 posted (author Kent Cooper) allows to split the dimension in one go.
(apply ''((a b c)(a b c))
  '(
    (( f L ) (apply 'strcat (f L)))
    (( L ) (if L (cons (chr (car L)) (f (cdr L)))))
    (72 101 108 108 111 32 87 111 114 108 100)
  )
)
vevo.bg

kdub_nz

  • Mesozoic keyThumper
  • SuperMod
  • Water Moccasin
  • Posts: 2166
  • class keyThumper<T>:ILazy<T>
Re: Spltting Dimensions
« Reply #13 on: May 25, 2016, 04:18:16 AM »
When I originally wrote that it was just proof of concept.

I still use it as is ...
Called Kerry in my other life
Retired; but they dragged me back in !

I live at UTC + 13.00

---
some people complain about loading the dishwasher.
Sometimes the question is more important than the answer.

MSTG007

  • Gator
  • Posts: 2606
  • I can't remeber what I already asked! I need help!
Re: Spltting Dimensions
« Reply #14 on: May 25, 2016, 07:18:03 AM »
Its funny how you see your code just pop up here and there I bet! It is a nice piece to get things labeled up quickly. I know I have been messing around with the standard dimensioning tool in CAD with the continuous dimension option. But it works to a degree but also takes a lot more clicks rather than yours where you just click click click and done! Great job on the concept and all.
Civil3D 2020