7 Replies Latest reply on Nov 20, 2018 3:53 PM by Maciej Mazik

    How to add fixed face?

    Maciej Mazik

      Hello

      What line code I need to add, if I have selected face, and want add fixed?

        • Re: How to add fixed face?
          Mandar Parkhi

          Can you elaborate what you mean by fixed, and why you want to do that, in which environment ?

            • Re: How to add fixed face?
              Maciej Mazik

              By fixed I mean to block rotation and move a face in Mesh. VB

                • Re: How to add fixed face?
                  Mandar Parkhi

                  Ok. Are you using simulation APIs to automate meshing ?

                      • Re: How to add fixed face?
                        Mandar Parkhi

                        Hi Maciej, Here is my program. Is this what you are looking for ?

                        ---VB.NET program for fixing face in FEA.JPG

                        Imports System.Runtime.InteropServices

                        Imports CosmosWorksLib

                        Imports SldWorks

                        Imports SwConst

                         

                         

                        Public Class Form1

                         

                         

                            Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click

                                Dim swapp As SldWorks.SldWorks

                                Dim swpart As SldWorks.PartDoc

                                Dim swmodel As SldWorks.ModelDoc2

                                Dim swent As SldWorks.Entity

                                Dim swxobjstring As String = "SldWorks.Application.26"

                               

                                Dim COSMOSWORKS As Object

                                Dim COSMOSObject As CwAddincallback

                                Dim ActDoc As CWModelDoc

                                Dim StudyMngr As CWStudyManager

                                Dim Study As CWStudy

                                Dim LBCMgr As CWLoadsAndRestraintsManager

                              

                                Dim CWRes1 As CosmosWorksLib.CWRestraint

                         

                         

                                Try

                                    swapp = Marshal.GetActiveObject(swxobjstring)

                                    swapp.Visible = True

                                Catch ex As Exception

                         

                         

                                End Try

                         

                         

                                If swapp Is Nothing Then

                         

                         

                                    Dim acType As Type = Type.GetTypeFromProgID(swxobjstring)

                                    swapp = CType(Activator.CreateInstance(acType, True), SldWorks.SldWorks)

                                    swapp.Visible = True

                                End If

                         

                         

                                swpart = swapp.ActiveDoc

                         

                         

                                COSMOSObject = swapp.GetAddInObject("SldWorks.Simulation")

                                COSMOSWORKS = COSMOSObject.CosmosWorks

                                swmodel = swapp.ActiveDoc

                                ActDoc = COSMOSWORKS.ActiveDoc()

                         

                         

                                StudyMngr = ActDoc.StudyManager()

                                Study = StudyMngr.GetStudy(0)

                         

                         

                                swent = swpart.GetEntityByName("leftface", swSelectType_e.swSelFACES)

                                swent.Select4(False, Nothing)

                         

                         

                                Dim DispatchObj As Object

                                DispatchObj = swmodel.SelectionManager.GetSelectedObject6(1, -1)

                         

                         

                                Dim vararray As Object

                                vararray = {DispatchObj}

                         

                         

                                LBCMgr = Study.LoadsAndRestraintsManager

                                Dim ercode As Integer

                                CWRes1 = LBCMgr.AddRestraint(0, vararray, Nothing, ercode)

                         

                         

                            End Sub

                        End Class