How To: Horizontal alignment dimension (draft)

Creator
Creator

I'm trying to implement a modify dimension button which sets the orientation of the leader to horizontal. See image below for clarification.

 

Dimension - horizontal leader.jpg

 

Method:

  1. User selects the dimension(s)
  2. Button click
  3. Sets the alignment to horizontal

 

To do this in solidedge: properties dimension --> tab 'Text' --> Orientation 'Horizontal'

Settings - dimension.jpg

 

Got this code so far:

SEDraftDocument = SEApplication.ActiveDocument
SESelectSet = SEDraftDocument.SelectSet

Dim SEActiveDimensionStyles As SolidEdgeFrameworkSupport.DimensionStyles
SEActiveDimensionStyles = SEDraftDocument.DimensionStyles
Dim SEActiveDimesionStyle As SolidEdgeFrameworkSupport.DimensionStyle

If SESelectSet.Count = 0 Then
                    Form_InfoNoDimension.Show()
                Else
                    For i As Integer = 1 To SESelectSet.Count
                        Dim SESelectSetItem As SolidEdgeFrameworkSupport.Dimension
                        SESelectSetItem = SESelectSet.Item(i)
                        For j As Integer = 1 To SEActiveDimensionStyles.Count
                            SEActiveDimesionStyle = SEActiveDimensionStyles.Item(j)
                            SEActiveDimesionStyle.OverridePulledOutText2 = True
                            
                        Next
                    Next
                End If

Also tried to monitor the procedure through Event Monitor.

 

SEApplication.StartCommand(10999)

SEApplication.StartCommand(10914)

SEApplication.StartCommand(45000)

 

But that only brings up or closes the properties window.

Thanks in advance for the help.

 

With kind regards,

 

Rick

5 REPLIES

Re: How To: Horizontal alignment dimension (draft)

Phenom
Phenom

I've literally been working on exactly the same thing.

 

If you want to select the dims then click the button, I did this (it's C# but I'm sure you can see what's going on).

  void _setHorizClicked(RibbonControl control)
        {

            application = MyAddIn.Instance.Application;
            SolidEdgeDraft.DraftDocument currentDoc = application.GetActiveDocument<SolidEdgeDraft.DraftDocument>();

            if (currentDoc != null)
            {
               
                var selection = application.ActiveSelectSet;

                if (selection.Count > 0)
                {
                    for (int i = 1; i <= selection.Count; i++)
                    {
                        var curItem = selection.Item(i);
                        Type curType = SolidEdgeCommunity.Runtime.InteropServices.ComObject.GetType(curItem);

                        if (curType == typeof(SolidEdgeFrameworkSupport.Dimension))
                        {
                            SolidEdgeFrameworkSupport.Dimension curDim = (SolidEdgeFrameworkSupport.Dimension)curItem;

                            var style = curDim.Style;

                            style.TextOrientation = SolidEdgeFrameworkSupport.DimTextOrientationConstants.igDimStyleTextHorizontal;
                        }
                    }
                }
            }
        }

However, I improved it, so that clicking the button would enter the command, so you could then just go around and click the dims you want to change, then Esc to finish.

 

 private void CreateHorizontalCommand()
        {
            try
            {
                application = MyAddIn.Instance.Application;
                _command = application.CreateCommand(2);//((int)SolidEdgeConstants.seCmdFlag.seNoDeactivate);
                _command.Terminate += command_Terminate_Horiz;
                _command.Start();

                _mouse = _command.Mouse;
                _mouse.LocateMode = (int)SolidEdgeConstants.seLocateModes.seLocateQuickPick; 
                _mouse.EnabledMove = false;
                _mouse.ScaleMode = 1;   
                _mouse.WindowTypes = 1; 
                _mouse.AddToLocateFilter(SolidEdgeConstants.seLocateFilterConstants.seLocateDrivingDimension);
                _mouse.MouseDown += mouse_MouseDown_Horiz;
            }

            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }

        private void mouse_MouseDown_Horiz(short sButton, short sShift, double dX, double dY, double dZ, object pWindowDispatch, int lKeyPointType, object pGraphicDispatch)
        {
            if (_mouse == null) return;

            Type graphicDispatchType = null;
            if (pGraphicDispatch != null)
            {
                graphicDispatchType = SolidEdgeCommunity.Runtime.InteropServices.ComObject.GetType(pGraphicDispatch);

                if (graphicDispatchType == typeof(SolidEdgeFrameworkSupport.Dimension))
                {
                    SolidEdgeFrameworkSupport.Dimension curDim = (SolidEdgeFrameworkSupport.Dimension)pGraphicDispatch;

                    var style = curDim.Style;

                    style.TextOrientation = SolidEdgeFrameworkSupport.DimTextOrientationConstants.igDimStyleTextHorizontal;
                }
            }

        }

        private void command_Terminate_Horiz()
        {
            //HandleCommandTerminate();          

            _mouse = null;
            _command = null;
            application = null;
        }

 

Re: How To: Horizontal alignment dimension (draft)

Solution Partner Legend Solution Partner Legend
Solution Partner Legend

Hi Rick,

 

seems you're just missing to set also the SEActiveDimesionStyle property PulledOutText2Orientation to igDimStyleTextHorizontal (Value 1).

 

Kind regards,
Wolfgang Kunert - www.wksyspro.de

Re: How To: Horizontal alignment dimension (draft)

Creator
Creator

Thanks Alex, and glad to see i'm not the only one!

Nice piec of code.

I can see where you going with it.

 

In my case: I have a couple of other buttons which also modify the dimensions.

All with the method that the user selects the dimensions and then clicks the button.

But your way, firstly access the command and than change dimensions accordingly is another way to look at it.

 

Wolfgang that was the command line i was looking for, missed that one.

Just one more step i think. Now when i select a dimension and click the button, it seems that nothing happens. But it sets the OverridePulledOutText2 to True and the PulledOutText2Orientation to horizontal. The dimension(s) that i place next will be with horizontal leader, but not the one(s) firstly selected.

 

Modified the code to:

SEDraftDocument = SEApplication.ActiveDocument
                SESelectSet = SEDraftDocument.SelectSet

                Dim SEActiveDimensionStyles As SolidEdgeFrameworkSupport.DimensionStyles
                SEActiveDimensionStyles = SEDraftDocument.DimensionStyles
                Dim SEActiveDimesionStyle As SolidEdgeFrameworkSupport.DimensionStyle

                If SESelectSet.Count = 0 Then
                    Form_InfoNoDimension.Show()
                Else
                    For i As Integer = 1 To SESelectSet.Count
                        Dim SESelectSetItem As SolidEdgeFrameworkSupport.Dimension
                        If SESelectSet.Item(i).Name.Contains("Dimension") = True Then
                            SESelectSetItem = SESelectSet.Item(i)

                            For j As Integer = 1 To SEActiveDimensionStyles.Count
                                SEActiveDimesionStyle = SEActiveDimensionStyles.Item(j)
                                SEActiveDimesionStyle.OverridePulledOutText2 = True
                                SEActiveDimesionStyle.PulledOutText2Orientation = 1
                            Next

                        Else
                            Continue For
                        End If
                    Next
                End If

Goal is to change only the one(s) selected.

 

 

Re: How To: Horizontal alignment dimension (draft)

Solution Partner Legend Solution Partner Legend
Solution Partner Legend

Rick,

 

you could try to use the Style property, returning a DimStyle object, of an selected Dimension object to change its values only.

 

... 
SESelectSetItem = CType(SESelectSet.Item(i), SolidEdgeFrameworkSupport.Dimension)

SESelectSetItem.Style.OverridePulledOutText2 = True
SESelectSetItem.Style.PulledOutText2Orientation = 1
...

 

 

Kind regards,
Wolfgang Kunert - www.wksyspro.de

Re: How To: Horizontal alignment dimension (draft)

Creator
Creator

Wolfgang!

 

That's the solution! Thanks very much!

I was stuck on trying to get it to work with the For loop (in the select set For loop)

Now the button works as a charm.

 

I can drag a box around the region of dimensions i want to change.

And whether or not the selection contains drawing views, when i click the button only the dimensions will be modified to have an horizontal leader.

 

If SENoDocuments() = True Then
            MsgBoxNoDocuments()
        Else

            If SENoDraftDocument() = True Then
                MsgBoxNoDraftDocument()
            Else

                SEDraftDocument = SEApplication.ActiveDocument
                SESelectSet = SEDraftDocument.SelectSet

                If SESelectSet.Count = 0 Then
                    Form_InfoNoDimension.Show()
                Else
                    For i As Integer = 1 To SESelectSet.Count
                        Dim SESelectSetItem As SolidEdgeFrameworkSupport.Dimension
                        If SESelectSet.Item(i).Name.Contains("Dimension") = True Then
                            SESelectSetItem = CType(SESelectSet.Item(i), SolidEdgeFrameworkSupport.Dimension)
                            SESelectSetItem.Style.OverridePulledOutText2 = True
                            SESelectSetItem.Style.PulledOutText2Orientation = 1
                        Else
                            Continue For
                        End If
                    Next
                End If
            End If
        End If

 

Gratitude!!