Dimension Segment - Select a specific segment with a mouse click

Dimension Segment - Select a specific segment with a mouse click

Anonymous
Not applicable
2,757 Views
11 Replies
Message 1 of 12

Dimension Segment - Select a specific segment with a mouse click

Anonymous
Not applicable

I have looked all over (web, forums, SDK, Building Coder, and etc) for a code snippet that would allow me to select a specific dimension segment in a multi-segment dimension through a mouse click. I have come up empty.  

 

I can get a specific segment using its array index, but when clicking on a dimenison in the middle of a command, I cannot get that segment's array index value.

 

Is it possible to get the specific index or the individual segment itself?  I would greatly appreciate a pointer in the right direction if its possible.

 

Thanks,

Keith

0 Likes
Accepted solutions (1)
2,758 Views
11 Replies
Replies (11)
Message 2 of 12

Aaron.Lu
Autodesk
Autodesk
Dear KEITH,

You can use mouse click to select the segment, but you can get what you selected in API, because it is niether an element nor a geometry object .
May I know why do you what to do that?


Aaron Lu
Developer Technical Services
Autodesk Developer Network
0 Likes
Message 3 of 12

Aaron.Lu
Autodesk
Autodesk
Excuse me, some typos:
you can get what you selected in API ==> you canNOT get what you selected in API.

Niether ==> neither


Aaron Lu
Developer Technical Services
Autodesk Developer Network
0 Likes
Message 4 of 12

Anonymous
Not applicable

Thanks for the follow-up.  Your response is what I expected, but not what I hoped for as the actual response.

 

As for the reason I would need the ability to get the selected dimension segment is so that I can increase efficiency when updating dimension segments with text in the prefix, suffix, above, and below positions.  Right now we have two choices to perform this work.  Each is described below:

 

1) Create a multi-segment dimension string and then double-click each individual segment to update the display with the desired text.  This effort requires numerous clicks and often results in accidentally dragging the dimension text away from its home location.  Once in the dialog to add the text, we must either type out the desired string, or perform repetative paste actions.

 

2) Create a mulitude of singel segment dimension strings which require a lot of duplicate clicking steps to create a seemingly long single appearing dimension string.  Then we can perform the same repetative tasks as noted in step one updating each dimension string, or we can use a custom tool using the API to automatically and repetatively update the text for us with each subsequent click o na dimension string.  Our code works really well with the single segment dimension, but does not work on the multi-segmented dimension.

 

A practical use for this would be on an elevation where we are calling out each precast concrete panel width and the joints between them.  Being able to select the individual segments via the API would allow us to set the text value at the start of the command and then select each of the segments that get the text string added. If the elevation has 50 panels on it then there are 49 joints.  Performing these repetative steps requires hundreds of mouse clicks which can be cut in half with the use of a custom tool through the API.

 

This would be a needed addition to the API for multi-segment dimensions.

 

Keith

0 Likes
Message 5 of 12

Aaron.Lu
Autodesk
Autodesk

Not sure if I understand clearly.

what about create multi-segment dimensions, and click them manually or filter them automatically and iterate the segments inside the dimension, and then update strings of them?

Because for multi-segment dimension, it has a property Dimension.Segments to get all the sub-segments, then you can change each segment's suffix, prefix etc.



Aaron Lu
Developer Technical Services
Autodesk Developer Network
0 Likes
Message 6 of 12

Anonymous
Not applicable

Your noted method to update all segments with the same string is usable, but only if each and every segment had the same text value.  It does not work for multiple, or alternating text values.  

 

I have attached a quick video of the two methods (copmressed in a zip file).  The first part is the manual method which is painful when we work on large projects with many joints between the elements.  The second part, and much shorter in time, uses individual dimension segments (which requires many more up-front clicks to generate) and custom tools that we have written to speed the process of added the desired text string.  The only problem is, dimensions are always put in using multiple segments.

 

Hopefully the video will make it clear what I am trying to accomplish with multi-segmented dimensions.  

 

Keith

0 Likes
Message 7 of 12

Aaron.Lu
Autodesk
Autodesk
Thanks for the video, let me repeat what you meant, you want to:
1. automatically update a batch of text of dimensions (or segments) and then sometimes
2. update some of them seperately by clicking on them, because they are not always uniform,
e.g. some text is set by accident or some is different with other texts by design.

#1 is not a problem, #2 is not a problem with dimension but impossible for dimension-segment.

right? If I understand correctly, may I suggest the following way to handling #2 problem for dimension segment?
* run the addon
* select the multi-segment dimension
* propmt what you want to do to dimension segment, e.g. change suffix
* pick point which is close to the target segment
* the addon calcuate which segment is close to the point and update the segement text.
* repeat pick point

Tip:
# use PickPoint to pick a point in the document
# use DimensionSegment.Origin to get the position of the segment.


Aaron Lu
Developer Technical Services
Autodesk Developer Network
0 Likes
Message 8 of 12

Anonymous
Not applicable

Aaron - Thanks for the continued follow up.  I like your idea.  Why didn't I think of that before?  

 

I will want my utilitity to be able to switch seemlesy between using element selection (single segment dimensions) and using pick-point for multi-segment dimensions becuase there is no planning for what the user will actually include in the model at any given time.  So I think there is going to be some logic work to be done within the code for the tool.  

 

I will give this a shot and see if I have any further issues.  Thanks for your help.  

 

If you have any ideas on getting two selections at the same time (element and point in space) that would be greatly appreciated.  

 

Keith

0 Likes
Message 9 of 12

Aaron.Lu
Autodesk
Autodesk
Accepted solution
I'm afraid you can 🙂

{code}
var reference = uiSel.PickObject(Autodesk.Revit.UI.Selection.ObjectType.Element, "statusPrompt");
TaskDialog.Show("point", reference.GlobalPoint.ToString());
{code}


Aaron Lu
Developer Technical Services
Autodesk Developer Network
Message 10 of 12

Anonymous
Not applicable

Thanks Aaron. After your previous post I edited my tools to recognize when a dimension string had multiple segments and prompt the user to pick a segment which was used with GlobalPoint and DistanceTo.  This required a second pick for each segment, but was still automated.  It didn't occur to me that the selection reference also has a GlobalPoint which can be used with DistanceTo to get the closest segment in the multi-segment dimension.  

 

Now, I can iterate over the DimensitonSegmentArray and compare distances to the reference pick point. I can then get the specific segment picked upon and its index in the array using the single GlobalPoint of the pick reference.

 

Thanks again!

 

Keith

0 Likes
Message 11 of 12

Aaron.Lu
Autodesk
Autodesk
Cheers!


Aaron Lu
Developer Technical Services
Autodesk Developer Network
0 Likes
Message 12 of 12

zrodgersTSSSU
Advocate
Advocate

Do you have your code for this still?

0 Likes