Reply

Expose Variable

[ Edited ]

 

 

Can anyone tell me how to expose a variable using Visual Basic

 

Posted by: Eddie Miller
Post date: 12/17/2008 4:46:08 AM

15 REPLIES

RE: Expose Variable

[ Edited ]

Hi

 

 

Set Variables = objDoc.Variables

MaterialThickness = Variables.Item("MaterialThickness").Value

PlateArea = Variables.Item("Plate_Area").Value

 

Cheers

Snow

 

 

Posted by: Snow Mackenzie
Post date: 12/21/2008 6:02:03 PM

Re: RE: Expose Variable

Hi,

 

How change a expose name of exist variable ?

Re: RE: Expose Variable

Try this :

 

Variables.Item("MaterialThickness").ExposeName = "MatThick"

Variables.Item("MaterialThickness").Expose = True

 

Romuald


Romuald BERTIN

Re: RE: Expose Variable

Hi,

 

OK works fine, but it crush when variable have already expose name...

What i should do ?

Re: RE: Expose Variable

The following code worksfine for me :

        Try
            _application = CType(Marshal.GetActiveObject("SolidEdge.Application"), SolidEdgeFramework.Application)
        Catch ex As Exception
            If Not (_application Is Nothing) Then
                Marshal.ReleaseComObject(_application)
                _application = Nothing
            End If
            MsgBox("Cannot connect to Solid Edge.")
            End
        End Try

        Try
            objDoc = _application.ActiveDocument
            If objDoc Is Nothing Then
                If Not (_application Is Nothing) Then
                    Marshal.ReleaseComObject(_application)
                    _application = Nothing
                End If
                MsgBox("No active File.")
                End
            End If
        Catch ex As Exception
            If Not (_application Is Nothing) Then
                Marshal.ReleaseComObject(_application)
                _application = Nothing
            End If
            MsgBox("No active File.")
            End
        End Try

        Dim objVars As SolidEdgeFramework.Variables = objDoc.Variables
        Dim objVar As SolidEdgeFramework.variable
        objVar = objVars.Item("MaterialThickness")
        objVar.ExposeName = "MatThick"
        objVar.Expose = True

Maube your problem is that another variable is exposed with the same name.


Romuald BERTIN

Re: RE: Expose Variable

Hi Romuald,

Thanks i will check it later. I have another question, because still i have problem to expose flat pattern variable... i have ST6

 

                objApp = Marshal.GetActiveObject("SolidEdge.Application")
                If objApp Is Nothing Then
                    MessageBox.Show("Solid Edge should be running.", sTitle, MessageBoxButtons.OK, MessageBoxIcon.Error)
                    End
                End If
                objApp.Activate()
                objPartDocument = objApp.ActiveDocument
                objFlatPatternModels = objPartDocument.FlatPatternModels
                If objFlatPatternModels.Count > 0 Then

                    objFlatPatternModel = objFlatPatternModels.Item(1)
                    objFlatPatterns = objFlatPatternModel.FlatPatterns



                    If objFlatPatterns.Count > 0 Then

                        Dim oMaxCutSizeX As Double = 0.0
                        Dim oMaxCutSizeY As Double = 0.0
                        Dim oShowRangeBox As Boolean = False
                        Dim oAlarmOnX As Boolean = False
                        Dim oAlarmOnY As Boolean = False
                        Dim oUseDefaultValues As Boolean = True


                        For a = 1 To objFlatPatterns.Count

                            oshowdim = objFlatPatterns.Item(a)
                            Try
                                oshowdim.SetCutSizeValues(MaxCutSizeX:=oMaxCutSizeX, MaxCutSizeY:=oMaxCutSizeY, ShowRangeBox:=True, AlarmOnX:=oAlarmOnX, AlarmOnY:=oAlarmOnY, UseDefaultValues:=False)
                            Catch ex As Exception

                                If Not (objApp Is Nothing) Then
                                    Marshal.ReleaseComObject(objApp)
                                    objApp = Nothing
                                    MsgBox("Show cut size range and dimensions manually", MsgBoxStyle.Critical)
                                End If
                                Return
                            End Try
                        Next

Could you check my code for me.

Re: RE: Expose Variable

Hi Lauren,

 

I haven't got any problem with your code.

What are you trying to do with it ?

 

This code only redefine the CutSize options that will set an alarm if the dimensions of the flatpattern are bigger than the max cut sizes.


Romuald BERTIN

Re: RE: Expose Variable

I need a variable Flat_Pattern_Model_CutSizeX and Y do describe a plate dimensions

To do that first, i must show a cut size range, without this those variable are not active.

So i`d like to my macro do that.

Re: RE: Expose Variable

Lauren,

 

you could try

 

...

oshowdim.ShowDimensions=True

...

 

to achieve what you want.

Then you should be able to expose the named variables.

 

Kind regards,
Wolfgang Kunert - www.wksyspro.de