Selecting multiple extension line functionality help

Selecting multiple extension line functionality help

adkstorm
Participant Participant
2,988 Views
21 Replies
Message 1 of 22

Selecting multiple extension line functionality help

adkstorm
Participant
Participant

Have this routine I use often, but it only allows you to select one extension line. I would like to be able to select multiple, so I don't have to repeat the routine for each extension line I select.

 

(defun c:nox(/ notdim stillon tryext oce es en pt ed)
  ;Return T if <edata> is not a dimension
  (defun notdim (edata)
   (/= "DIMENSION" (cdr (assoc 0 edata))))
 (defun stillon (edata pnt / ssp)
  (if (setq ssp (ssget pnt))
   (equal
    (cdr (assoc -1 edata))
    (ssname ssp 0))))
 ;Return T if extension goes away, nil otherwise
 (defun tryext (extnum edata pnt)
  (command "dim" "override" (strcat "dimse" (itoa extnum)) "on" "" en "")
  (cond
   ((stillon edata pt)
    (command "undo" "exit")
    nil)
   (t
    (command "exit")
    'T)))
 ;Main:
 (setq oce (getvar "cmdecho"))
 (setvar "cmdecho" 0)
 (command "undo" "g")
 (if (setq es (entsel "\nPick extension line to suppress: "))
  (progn
   (setq
    en (car es)
    pt (cadr es)
    ed (entget en))
   (cond
    ((notdim ed)
     (princ "\nNot a dimension."))
    ((tryext 1 ed pt))
    ((tryext 2 ed pt))
    ((princ "\nNot an extension line.")))))
 (command "undo" "e")
 (setvar "cmdecho" oce)
 (princ))
0 Likes
Accepted solutions (1)
2,989 Views
21 Replies
Replies (21)
Message 2 of 22

ВeekeeCZ
Consultant
Consultant

@adkstorm wrote:

Have this routine I use often, but it only allows you to select one extension line. I would like to be able to select multiple, so I don't have to repeat the routine for each extension line I select.

 

(defun c:nox(/ notdim stillon tryext oce es en pt ed)
  ;Return T if <edata> is not a dimension
  (defun notdim (edata)
   (/= "DIMENSION" (cdr (assoc 0 edata))))
 (defun stillon (edata pnt / ssp)
  (if (setq ssp (ssget pnt))
   (equal
    (cdr (assoc -1 edata))
    (ssname ssp 0))))
 ;Return T if extension goes away, nil otherwise
 (defun tryext (extnum edata pnt)
  (command "dim" "override" (strcat "dimse" (itoa extnum)) "on" "" en "")
  (cond
   ((stillon edata pt)
    (command "undo" "exit")
    nil)
   (t
    (command "exit")
    'T)))
 ;Main:
 (setq oce (getvar "cmdecho"))
 (setvar "cmdecho" 0)
 (command "undo" "g")
 (while (setq es (entsel "\nPick extension line to suppress: "))
  (progn
   (setq
    en (car es)
    pt (cadr es)
    ed (entget en))
   (cond
    ((notdim ed)
     (princ "\nNot a dimension."))
    ((tryext 1 ed pt))
    ((tryext 2 ed pt))
    ((princ "\nNot an extension line.")))))
 (command "undo" "e")
 (setvar "cmdecho" oce)
 (princ))

 

This little mod allows you to pick quickly one after another. But making it a multiple selection as a window type fashion would be very complicated, rather impossible.

What can be done is multiple dim selection - it that case both extension lines would be turned off for all selected dims. Not sure if that helps you to streamline your workflow.

 
0 Likes
Message 3 of 22

Kent1Cooper
Consultant
Consultant
Accepted solution

@adkstorm wrote:

Have this routine I use often, but it only allows you to select one extension line. I would like to be able to select multiple, so I don't have to repeat the routine for each extension line I select.

....


This has been my inducement to edit DimExtLineToggle.lsp with its DET command [attached] to allow selecting as many as you want in one running of the command.  It has some differences from yours, which I hope you will consider advantages:

 

It's a toggle, that is, it doesn't only turn the appropriate extension line off, but turns it off if it's on, or turns it on if it's off.

 

Because of the turning-on-if-it's-off, obviously it can't require you to select on  an extension line that's suppressed, so you can pick anywhere  on the Dimension nearer to the end whose extension line you want to toggle -- on the extension line [if it's showing], or the arrowhead, or the dimension line, or even the text.  So, even in the case of turning one off, there's this advantage where there are coinciding/overlapping extension lines belonging to more than one  Dimension:

DET.PNG

 

Also because you don't need to pick on the extension line itself, it uses a different method to determine which end of the Dimension you picked closer to, accounting for various conditions such as obliquing, and forbidding things like radial/diameter dimensions that don't have  extension lines.

 

You can pick on as many as you like, until you hit Enter/space, or ESCape, or pick in empty space.  [It could be enhanced further to ask again if you miss, but another time....  It does  ask again if you pick on some inappropriate object type.]

Kent Cooper, AIA
0 Likes
Message 4 of 22

anton_chmidt
Advocate
Advocate

This is great lisp Kent. I Would need something like this but instead of toggling it completely off I would need to toggle it to different linetype (for example linetype named KL), would this be possible to code? Of course if user could change the linetype in lisp settings, it would be even better. 

EDIT: Here is example of end result where I used your DET lisp to quickly determine which lines I would need work with by letting the DET command toggle them off, then manually turned them back on for both dimensions and changed linetype of said lines to KL

 

Example of KL line.png



0 Likes
Message 5 of 22

Kent1Cooper
Consultant
Consultant

@anton_chmidt wrote:

... instead of toggling it completely off I would need to toggle it to different linetype .... 


That should be possible, but confirm [or correct] some things:

If the closer extension line of a selected Dimension is currently off, I assume you would want it turned on as well as changed to your specified linetype.

The possibility that it's off means you can't count on being able to select on the extension line itself, but may need to pick on some other nearby part [arrow/tick, dimension line, text].  So I assume it would be acceptable, for two Dimensions that share an extension line location, to not pick on that shared extension line once and apply it to both Dimensions [your description sort of sounds like that], but to be required to do it individually to both, or to just do it to one of the Dimensions and turn that extension line of the other one off.  [And after all, there could be any number of Dimensions that share a common extension line location, and even if only two, they could be of different lengths.  That means applying a non-continuous linetype to them all/both could result in a continuous effect anyway, because the dash parts of some could write over the gap parts of others.  So applying it to only the longest one, and turning off the overlapping extension lines of any other(s), is probably preferable.]

Kent Cooper, AIA
0 Likes
Message 6 of 22

anton_chmidt
Advocate
Advocate

If the closer extension line of a selected Dimension is currently off, I assume you would want it turned on as well as changed to your specified linetype.

 

indeed this is preferable, but not absolutely necessary.

 

The possibility that it's off means you can't count on being able to select on the extension line itself, but may need to pick on some other nearby part [arrow/tick, dimension line, text].  So I assume it would be acceptable, for two Dimensions that share an extension line location, to not pick on that shared extension line once and apply it to both Dimensions [your description sort of sounds like that], but to be required to do it individually to both, or to just do it to one of the Dimensions and turn that extension line of the other one off.  [And after all, there could be any number of Dimensions that share a common extension line location, and even if only two, they could be of different lengths.  That means applying a non-continuous linetype to them all/both could result in a continuous effect anyway, because the dash parts of some could write over the gap parts of others.  So applying it to only the longest one, and turning off the overlapping extension lines of any other(s), is probably preferable.]

 

I agree with every point and assumption you made here! Indeed when done manually often the dashes interrupt with each other making the line look weird. So I think turning rest of them ( usually one) off would be best option here. It is smartest to to turn the longest of them to dashed. Honestly you are amazing me by how well you have tought this through. I didn't even dare to bring such problems up while asking you with this feature. I was assuming that I'm going to have to hope that multiple lines will line up nicely or I'll going to have to play with them manually. But you are talking here about fixing the problem all together!

 

One problem I can see coming is the linetype. Our workflow is to take old project and use that old dwg to create something new with it. Since there are multiple different scales and hundreds of old projects to pick from, it is very hard to name one linetype name which would work all the time. Any ideas how make lasting solution to this? Maybe something like a settings option where user can name the linetype which must exist in dwg? But honestly I can also take the option where it is "KL" by default and had be changed in lisp code itself. I can then try to work on some solution where I always bring object with said linetype to every dwg so the KL will always be available

0 Likes
Message 7 of 22

anton_chmidt
Advocate
Advocate
Did I answer all of your questions? Any more info needed? So basically I am confirming all things as you suggested / assumed
0 Likes
Message 8 of 22

Kent1Cooper
Consultant
Consultant

I worked on that some, and found a complication -- the linetype in question is not stored in entity data as a linetype name, but in a more inscrutable way -- but I think I have found a way to do it.  I'm thinking about how to load a linetype you specify if it's not in the drawing nor in AutoCAD's linetype file.  I think I can come up with something soon if it doesn't need to check for and load a linetype that might be anywhere.  Stay tuned....

 

EDIT:

Try the attached DimExtLineLtype.lsp with its DELO command [= Dimension Extension-line Linetype Override].

Limited testing, but it seems to work, including turning on extension lines that are off.  It works with ByLayer and ByBlock as well as regular linetypes.  It will find a linetype not already loaded in the drawing if it's in AutoCAD's file.  [<-- EDIT the lines so marked to refer to acadiso.lin if that's what you use.]  If you want one that is not yet loaded and not in AutoCAD's file, you will need to load it on your own first -- it could be made to look in a specific file or files for it if desired, or maybe to ask for the file to look in.

 

It does not find other coinciding extension line(s) for you [the overwriting-the-gaps question] -- you will need to turn them off if desired, whether in Properties, with the DET toggler, or otherwise.  It might be possible to find other Dimensions that share the extension line's location, and possibly to find which is longest to apply the linetype to and turn off others, but I expect that would be complicated [e.g. what if their definition points don't coincide?].

 

It asks again if you pick on the wrong kind of thing, or on a Dimension on a locked Layer, or on one without extension lines [diameter/radius/ordinate].  If you simply miss in picking, it ends the command, but presumably it could be made to ask again in that case, too.

Kent Cooper, AIA
Message 9 of 22

anton_chmidt
Advocate
Advocate

Thank you so much for this, this will be in my daily use everyday! With very quick testing seem to be working. I'll be using it for couple of days and let you know if any bugs or ideas comes up.

Some ideas to tackle the problem "not finding other coinciding extension line(s)". Could are selection be a solution? Because now most of the times I will be using the lisp two times to apply new linetype to both dimensions one by one. 90% of the time there will be two dimensions continued anyway. By choosing area selection user will be making a acknowledged decision to select all dimesnions for a lisp to work with. Alternatively It could ask if all other selected dimensions should get a DET treatment (Yes being default)? In both cases user will be aware of the decision to hide the rest dimlines. This way hopefully he can react if there is some other dimensions that should not be hidden.

0 Likes
Message 10 of 22

anton_chmidt
Advocate
Advocate

Found a bug. I changed your inital default linetype from CENTER to KL. On every first run it seem to offer the KL as a default, but when I press enter to accept the default offering (KL) it still try to change them to CENTER. Only if I manually type KL and then press enter it will work as intended. And from that point forward until lisp reloads / dwg is reopened

0 Likes
Message 11 of 22

Kent1Cooper
Consultant
Consultant

@anton_chmidt wrote:

Found a bug. I changed your inital default linetype from CENTER to KL. On every first run it seem to offer the KL as a default, but when I press enter to accept the default offering (KL) it still try to change them to CENTER. ....


Find the other place where "CENTER" occurs [I missed putting an <--EDIT pointer at one of them], and change that, too.

Kent Cooper, AIA
0 Likes
Message 12 of 22

anton_chmidt
Advocate
Advocate
I figured that might be the case in my own so found and replaced it. didn't seem to help at that time but maybe I didnt reload it or something. Probably my bad. I'll report back tomorrow after more precice testing
0 Likes
Message 13 of 22

Kent1Cooper
Consultant
Consultant

@anton_chmidt wrote:

....
Some ideas to tackle the problem "not finding other coinciding extension line(s)". Could are selection be a solution? ....


Assuming you mean area selection....  If you want all Dimensions in an area changed, then just select them and change those linetypes collectively in Properties.  The whole point of the routine is to determine for you which end to assign the linetype to, based on where you picked on a given Dimension, without your needing to know which end is extension line 1 and which is 2.  But that determination is impossible if you select the Dimensions collectively and not by picking at a location on each, and unnecessary if you want to do both extension lines of them all.

Kent Cooper, AIA
Message 14 of 22

anton_chmidt
Advocate
Advocate

I understand the main point, agree with it and it still stand with area selection, if area is small enough to just select all lines which are on top of each other in that one spot, not both ends. But I figure from your answer that is not a good solution or easily made in current lisp. So let's forget the area selection.

Yet hiding all the rest overlapping dimension lines ( or changing them also to same new linetype) would benefit greatly the main purpose of the lisp. There being at least two lines is very common, we use Dimcontinue all the time, so two dimensions always touching each other. And now user still need to figure out manually which of the dimensions got new linetype and then find a way to hide the other line manually. Of course it is easy with DET, just need to be careful not to hide the new linetype.

But please don't get me wrong, this is great lisp as it is. We are talking about perfecting it. For now I can just apply the new linetype two times to change both of lines that are on top of each other to new linetype.

0 Likes
Message 15 of 22

anton_chmidt
Advocate
Advocate

"Find the other place where "CENTER" occurs [I missed putting an <--EDIT pointer at one of them], and change that, too."

 

Sorry this was my bad.🤦Yesterday I did replace it eventually everywhere, but probably did not save before reloading lisp or something. Working now as expeted

0 Likes
Message 16 of 22

anton_chmidt
Advocate
Advocate

@Kent1Cooper wrote:

It does not find other coinciding extension line(s) for you [the overwriting-the-gaps question] -- you will need to turn them off if desired, whether in Properties, with the DET toggler, or otherwise.  It might be possible to find other Dimensions that share the extension line's location, and possibly to find which is longest to apply the linetype to and turn off others, but I expect that would be complicated 


Would it be easier / worth a try to just turn all coinciding extension line(s) to new linetype?

0 Likes
Message 17 of 22

Kent1Cooper
Consultant
Consultant

@anton_chmidt wrote:

.... 

Would it be easier / worth a try to just turn all coinciding extension line(s) to new linetype?


If they all come from the same definition points and go to the same dimension-line location.  When they don't, the dash parts of some will often overwrite the gap parts of others, in whole or in part:

Kent1Cooper_0-1698838848854.png

Both Dimensions have CENTER linetype for both extension lines.

 

[I was working on something to find multiple Dimensions at the same pick point, but I haven't figured out why it sometimes, but not always, sees more than one coinciding extension line at the same pick.  I'll try more experimenting to see if I can get it to be reliable.]

Kent Cooper, AIA
0 Likes
Message 18 of 22

anton_chmidt
Advocate
Advocate

Oh you are still working on this! Thank you very much! I know about that issue, I was just in believe that nothing can be done about said issue, in that case I would gladly take that compromise. 

 

Could the inconsistancy has something to do with the numbering of the extension lines. 1--22--1 and 1--21--2?

0 Likes
Message 19 of 22

anton_chmidt
Advocate
Advocate

Hi, Any news or progress on this Kent? 

0 Likes
Message 20 of 22

anton_chmidt
Advocate
Advocate
Would it be easy for you to add a option to do area selection to select all coinsiding extension lines? In my case I would make a very tiny area selection to pick just one small are where multiple coinciding extension lines are located. I can give you a real work situation as an example if needed.

But the easies way to make a example yourself is to just make a dim then dimcontinue that dim. Now you have three extension lines, then use this lisp to turn middle one into dashed. while keeping other two continuous. Thid is most common situation for me and I have to run the lisp twice selecting different dimension each time, sometimes there is as much as 8 overlapping dimensions and the process needs to be repeated 8 times and each time I need to pick new dimension one by one
0 Likes