How to connect with solid edge part file and change dimension values.

Hi all,

I am a newbie at solid edge programming. I've practiced API example using Solid edge API guide. and made a simple model using VB.net

I just want to know how to connect with part file which I model in the Solid edge and also how to change dimensions of the part.The part has a simple box shape.

Please let me know about connecting with solid edge and change variable using VB.net.

Many thanks to all in advance and have a nice day. 

 

 

 

 

 

Posted by: Doyoung Park
Post date: 10/20/2010 8:41:46 PM

2 REPLIES

RE: How to connect with solid edge part file and change dimension values.

A good start for you might be the (old but) good pdf "Customize Solid Edge" - you can find with google.

 

this is a starting point- not .net but old vb:

'Declare the program variables.Dim objApp As ObjectDim objVariables As ObjectDim objVariable As Object'Connect to a running instance of Solid Edge.Set objApp = GetObject(, "SolidEdge.Application")'Access the Variables collection.Set objVariables = objApp.ActiveDocument.Variables'Create a variable with distance unit type.Call objVariables.Add("Var1", "1.25", igUnitDistance)'Create a variable without specifying the unit type (defaults todistance).Call objVariables.Add("Var2", "3.56 cm")'Create a variable with area unit type.Call objVariables.Add("Var3", "Var1 * Var2", igUnitArea)'Iterate through all the variables, printing their name and value.For Each objVariable In objVariablesDebug.Print objVariable.Name & " = " & objVariable.ValueNext 
U can use the for each to go thru vars and check with if objVariable.Name = "myvar" if its the var u want to change then set the value objVariable.Value = 12 / 1000

 

Posted by: Linus Hechinger
Post date: 10/20/2010 10:32:38 PM

RE: How to connect with solid edge part file and change dimension values.

Thanks to Solid81 and all, 

To make it clear, I made a simple rectangular in Solid Edge and the rectangular has "height" and "width" dimensions.I wanted to change the value of two "height" and "width" values.

I'v just made a code based on your code. but i am using vb.net. I changed your code a little.When I executed my code, it changed two dimensions in the variable table. 

Now, I'd like to type some "height value" in a textbox  and want to look at changing dimension value automatically.I made simple form and there is a textbox. then, What should I do?I attached my code below. Please let me know how I can insert textbox to change dimension value. 

 

 

-----------------------------------------------------------------------------------------------------------------------Imports System.Runtime.InteropServicesImports SolidEdgeFramework

Module Module1

    Sub Main()

        Dim objapp As SolidEdgeFramework.Application = Nothing        Dim objVariables As SolidEdgeFramework.Variables = Nothing        Dim objVariable As SolidEdgeFramework.variable = Nothing

 

        Try            objapp = Marshal.GetActiveObject("solidedge.application")            objVariables = objapp.ActiveDocument.variables

            Call objVariables.Edit("height", 111)

        Catch ex As Exception            Console.WriteLine(ex.Message)

 

        End Try    End SubEnd Module

-----------------------------------------------------------------------------------------------------------------------

 

Thank you. 

 

 

 

 

Posted by: Doyoung Park
Post date: 10/20/2010 11:11:20 PM