Dimension extension Line to center bypick

Dimension extension Line to center bypick

DC-MWA
Collaborator Collaborator
2,442 Views
17 Replies
Message 1 of 18

Dimension extension Line to center bypick

DC-MWA
Collaborator
Collaborator

I have been seeking a lisp that allows me to pick a dimension extension line and set it to center2 linetype. The problem is the ones i have found do not work on overlapping dimensions.

I have a cool lisp that works great but it turns extension lines off and draws a line in place of two lines turned off. This makes for difficult editing later on.

I have attached the lisp, maybe one of you can assist me with making it turn one extension line off and change the linetype of one when over lapping or just change the linetype on both??

 

0 Likes
Accepted solutions (1)
2,443 Views
17 Replies
Replies (17)
Message 2 of 18

Kent1Cooper
Consultant
Consultant

@DC-MWA wrote:

I have been seeking a lisp that allows me to pick a dimension extension line and set it to center2 linetype. The problem is the ones i have found do not work on overlapping dimensions.

I have a cool lisp that works great but it turns extension lines off and draws a line in place of two lines turned off. This makes for difficult editing later on.

I have attached the lisp, maybe one of you can assist me with making it turn one extension line off and change the linetype of one when over lapping or just change the linetype on both??

 


 

I took my DimExtLineToggle.lsp routine with its DET command, available >here<, and made the attached modification to DimExtLineCENTER2.lsp with its DEC2 command, to do that.  Very quickie edit [I may not have caught everything that could be omitted from or should be re-worded in DET], and lightly tested.  It does not turn off the Extension line and draw a separate Line, but assigns the Linetype to the Extension line itself.  You can pick anywhere on the Dimension that's closer to the Extension line you want affected, on itself if it's visible [if the appropriate Extension line is suppressed, it turns it back on], or on the Dimension line, or the arrowhead, or the text.

 

The great bulk of it is devoted to determining whether it's Extension Line 1 or 2 that should be given the Linetype, so the User doesn't need to know which end is which, accounting for some extreme geometric relationships between definition points and Dimension line location, different Dimension varieties, etc.

 

It only does one -- if you have two overlapping, for now do it to both, or use DET to turn one off [also if they're different lengths and the dashes/gaps don't coincide, use DET on the shorter one].

Kent Cooper, AIA
Message 3 of 18

ronjonp
Mentor
Mentor

Maybe this?

(defun c:foo (/ e lt)
  ;; RJP » 2018-12-27
  (setq lt "Center")
  (or (tblsearch "LTYPE" lt) (command "linetype" "l" lt "acad.lin" ""))
  (while (and (setq e (nentsel "\nPick dimension line: "))
	      (= 4 (length e))
	      (= "LINE" (cdr (assoc 0 (entget (car e)))))
	 )
    (vla-put-linetype (vlax-ename->vla-object (car e)) lt)
    ;; Pick overlapping lines twice
    (command "_.draworder" (car (last e)) "" "_Back")
    (command "_.regen")
  )
  (princ)
)
(vl-load-com)
0 Likes
Message 4 of 18

DC-MWA
Collaborator
Collaborator

this works. If DEC.lsp would allow me to select both dims and process both it would be perfect.

😉

 

0 Likes
Message 5 of 18

Kent1Cooper
Consultant
Consultant

@ronjonp wrote:

Maybe this?


 

Interesting, but I find it doesn't "stick" -- if I alter the Dimension in any way, such as by dragging any grip [dimension-line location, text location, either  definition point -- not just the affected end], or even just Move or Rotate the overall Dimension, the affected extension line reverts  to the linetype it had before.  And even without doing that, while it still appears correct, that linetype assignment does not  show in the Properties palette.

Kent Cooper, AIA
0 Likes
Message 6 of 18

Kent1Cooper
Consultant
Consultant

@DC-MWA wrote:

this works. If DEC.lsp would allow me to select both dims and process both it would be perfect.


 

I'll have to think about that....  It works on one at a time because it depends on the pick location in relation to the rest of the individual Dimension's particulars to decide which end to affect.  So multiple selection can't be done with [for example] a window.  And just having it pick twice at the same location would usually result in its seeing the same Dimension both times.  How to pick more than one with presumably a single pick in a way that it can figure out what to do, and in a way that will work whether one or two [ever possibly more than two?] Dimension(s) is/are there, could be a challenge, but it may be doable.  In the meantime, it doesn't take long to whap the space bar and pick the second one, on its dimension line  [or arrowhead or even text] rather than on the overlapping extension lines, to avoid confusion -- one of the advantages of its not requiring picking on the extension line itself.

Kent Cooper, AIA
0 Likes
Message 7 of 18

DC-MWA
Collaborator
Collaborator
It's never more than two dimensions.

Maybe it's a matter of running DEC to pick one and DEX to turn of the under lying extension line.

I'm thinking maybe combine the two and have it dec the first pick and dex the second.

Some franken lisping if you will...

😉




0 Likes
Message 8 of 18

Kent1Cooper
Consultant
Consultant

@DC-MWA wrote:
....
Maybe it's a matter of running DEC to pick one and DEX to turn of the under lying extension line.
....

 

Assuming you're talking about my routines, and you really mean DEC2 and DET, there remains the complication that DET is named that way because it's a Dimension Extension-line Toggle, that is, turns the extension line off if it's on, or on if it's off.  So if a Dimension is identified and the extension line at that end is already off, it will turn it on, which presumably you don't want if the other Dimension there has had the linetype assigned.  But it could surely be franken-lisped to not  toggle, but just turn [or leave] that one off, if the selection aspect I described before can be worked out.

 

Also, are the extension lines ever of different lengths?  I.e., coming off different definition point positions, or going to dimension lines at different distances off the Dimensioned objects?  If so, presumably you want the longer one left on and the shorter suppressed [because the dashes and gaps are not likely to coincide if they're both on], which should be possible to determine, if one end at least is in the same place.  But there are certainly possible situations where one is longer at one end but shorter at the other -- I'm not sure what would be the best way to handle that....

Kent Cooper, AIA
0 Likes
Message 9 of 18

DC-MWA
Collaborator
Collaborator

DEC2 selects the first dim and changes the linetype. DET selects the second dim, and turns the line off.

Two clicks, one routine. DEC2 and DET combined.

Awesome!!!  just sayin...  🙂

0 Likes
Message 10 of 18

Kent1Cooper
Consultant
Consultant
Accepted solution

@DC-MWA wrote:

DEC2 selects the first dim and changes the linetype. DET selects the second dim, and turns the line off.

Two clicks, one routine. DEC2 and DET combined.

Awesome!!!  just sayin...  🙂


Try this [with both routines and the CENTER2 linetype already loaded in the drawing]:

 

(defun C:TEST () (C:DEC2) (C:DET))

 

You can pick anywhere on each Dimension involved, closer to their shared end than to each one's other end.  If you pick on their overlapping extension lines, it gives you control over which gets the linetype assigned.  It's easier for the second command to pick on the dimension line or arrowhead or text, so you don't need to specify again which Dimension for that.  Or, if you have the LTGAPSELECTION System Variable set to 0, and the overlapping is visible enough [newer versions of AutoCAD] and the gaps big enough, you can pick on the second one's extension line within one of the gaps in the other's that got the linetype assigned.

 

I'm trying to figure whether there's a way to pick once  on overlapping extension lines and achieve that result, or just do the linetype thing if there's only one Dimension there [it would able to tell -- an advantage over the TEST command above].  But here's the complication:  To select one  thing, as both those routines do, they use (entsel), and part of what that returns is the point at which you picked.  That's essential to figuring out which "end" of the Dimension you're at, to determine whether extension line 1 or 2 should be altered.  To select more than one  thing would require (ssget), and while there's an :E selection mode that would see everything at the pick point, so two such Dimensions could be selected with one pick, the return from (ssget) does not include anything about where that pick was.  But (ssnamex) can pull that information, so I'm investigating an approach using that.

 

If that works out, it would only work reliably when the extension lines are the same length and overlap over their entire length, because you would have no control over which of them got the linetype assigned and which got suppressed, which you do have control over with the two-pick scenario in the TEST command above.

Kent Cooper, AIA
0 Likes
Message 11 of 18

ronjonp
Mentor
Mentor

@Kent1Cooper wrote:

@ronjonp wrote:

Maybe this?


 

Interesting, but I find it doesn't "stick" -- if I alter the Dimension in any way, such as by dragging any grip [dimension-line location, text location, either  definition point -- not just the affected end], or even just Move or Rotate the overall Dimension, the affected extension line reverts  to the linetype it had before.  And even without doing that, while it still appears correct, that linetype assignment does not  show in the Properties palette.


That's too bad, it's such a simple solution 🙂

0 Likes
Message 12 of 18

DC-MWA
Collaborator
Collaborator

First, I apologize for the delay.

This works well. It requires two picks, but it does what i needed. I copied the dec and det lisps into one file, added the

"(defun C:TEST () (C:DEC2) (C:DET))" at the end. 

It works. I love the one I have been using because of it's simplicity to use one clock. But, later when editing, the drawn line place of extension line becomes an issue.

So... Thanks again my friend. If you happen to figure out the one pick overlapping solution.... that would be great. For now let's call it a win.

 

0 Likes
Message 13 of 18

GLTrippE7XB4
Community Visitor
Community Visitor

I like the "DIMEXTLINETOGGLE.LSP", it works great.

It would be great to have command similar to it that would toggle the selected extension line between "CENTER2" and "BYLAYER". Can you make something like this?

Grant

0 Likes
Message 14 of 18

Kent1Cooper
Consultant
Consultant

@GLTrippE7XB4 wrote:

I like the "DIMEXTLINETOGGLE.LSP", it works great.

It would be great to have command similar to it that would toggle the selected extension line between "CENTER2" and "BYLAYER". ....


I started to look into this.  I thought it should be easy to replace the appropriate pieces in the DIMOVERRIDE command that is used in DET, but oddly, DIMOVERRIDE doesn't recognize the appropriate Dimension variables [DIMLTEX1 & 2], either within AutoLisp code or when done manually.  Also, the information for an extension-line linetype override is stored inscrutably in extended data -- not just the name of the linetype, but a hexadecimal code somehow [it's "256" for CENTER2, but it's a hexadecimal text string, not just an integer, since it's for example "29E" for DOT].  And a Dimension with no overrides has no extended data to modify, so I'll need to get into how to add some if it can't be done via DIMOVERRIDE as it is in the DET command.  I'll check whether those variables are recognized in that command in a different version tomorrow, in case it's a version quirk [Acad2024 & 2025 here, 2020 at another location].

Kent Cooper, AIA
0 Likes
Message 15 of 18

Kent1Cooper
Consultant
Consultant

@Kent1Cooper wrote:

.... oddly, DIMOVERRIDE doesn't recognize the appropriate Dimension variables [DIMLTEX1 & 2], either within AutoLisp code or when done manually.  .....


That doesn't work in the older version at my other location, either.  Nor does the (get/setpropertyvalue) approach seem to be able to do it.

BUT I find it can be done with VLA properties.  I'll see if I can make that work....

EDIT:  Oh, wait....  Half of this is already in the routine at Message 2, with your specified linetype, but only forcing that on the extension line, not toggling between that and another linetype.  Working the toggling part into that will probably be simpler than working the linetype elements into the DET command.

Did you say CENTER2 because you want that specifically, or just because it's the linetype of the Topic?  In other words, should a linetype be hard-coded into it [different commands could be made for different linetypes], or would you want to be prompted for one, or perhaps for both?

Kent Cooper, AIA
0 Likes
Message 16 of 18

GLTrippE7XB4
Community Visitor
Community Visitor

Kent,

I said CENTER2 because that is our centerline type with our current drawing format. Finding that in the lisp file and be able change it to CENTER (or something else) in the future would be good.  On your comment above, I read it to be hard-coded to do one change. I do not want to be asked what to change it to.

What I want is to toggle (change) the extension line from BYLAYER to CENTER2 or from CENTER2 to BYLAYER. It would work just like your lisp command (DimExtLineToggle.lsp) that toggles the extension line off or on. Note, what I really like on the DimExtLineToggle.lsp I can select the dimension line near the extension line to turn that extension line off or on, that makes the lisp command clean and easy. Note, I am not looking to change both extension lines, just the one that I select nearest to.

Thanks.

0 Likes
Message 17 of 18

Kent1Cooper
Consultant
Consultant

... like the attached.  Lightly tested.  I did not update some things [such as the Undo begin/end approach] to the way I would typically do them in a new routine today.

 

It changes the linetype of the appropriate extension line to CENTER2 if it is currently anything other than that, not just if it's ByBlock, and it changes it to ByBlock only if it's currently CENTER2, not if it's anything else.  It could probably be made more sophisticated about the possibilities, if needed.

 

It forces the extension line in question on if it's off, because what's the point of changing its linetype otherwise?  But that can be omitted, if you want its linetype changed but not its visibility.

 

It would be easy to have it ask for a Linetype, to toggle between that and ByBlock, or for two to toggle between, and/or to use ByLayer instead of ByBlock, and so on.

Kent Cooper, AIA
0 Likes
Message 18 of 18

GLTrippE7XB4
Community Visitor
Community Visitor

THANK YOU!!!! It works GREAT! Your other comments are valid, but not for out kind of work. Detailing the structural decks sometimes going to center of beams or edges of plates and channels, with this lisp and the off/on lisp, we can make the dimensions clean, fast and more unified. 

Thank you again.

0 Likes