1 Reply Latest reply on Jul 19, 2015 12:45 PM by Kelson Lachance

    Support material for prototype machine

    Kelson Lachance

      I have search and search; before I go too far.

       

      Looking to build a quote module VBA api within Solidworks to calculate the amount of support material needed for our prototype machine.  Our machine is a Polyjet machine, so the support is measuring the unsupported ledges up the part based on part orientation.

       

      Looking for any suggestions on existing code or approaches before I go too far; and realize it is already out there, and I just missed it.

       

      Any help would be appreciated.

       

      I wrote some code which move a small thin block up and subtract off the main body.  At each level it will calculate the volume.

      It uses the Insert Combine feature.   It will error out in two cases; where there is a geometry condition as well as when the main body is consumed.

       

      Ideally I would like to get the error and define a specific action using an if statement.

       

      Any suggestions would be appreciated or possibly a better approach.

       

      Thanks,

       

      Kelson

       

       

       

       

      I am using the InsertCombine Feature

       

      Set myfeature = swModel.FeatureManager.InsertCombineFeature(15902, Nothing, Nothing)

        

         

        If myfeature Is Nothing Then

         swModel.ClearSelection2 True

         bRet = swModExt.SelectByID2("Cut" & "Step" & level & " i" & i, sBodyTypeSelStr, 0#, 0#, 0#, True, 2, Nothing, 0): Debug.Assert bRet

         Set myfeature = swModel.FeatureManager.InsertDeleteBody

       

       

      'just added

        bRet = swModExt.SelectByID2("Slice" & "Step" & level & " i" & i, sBodyTypeSelStr, 0#, 0#, 0#, True, 1, Nothing, 0): Debug.Assert bRet

        Set myfeature = swModel.FeatureManager.InsertDeleteBody

       

       

        End If

       

      Message was edited by: Kelson Lachance

        • Re: Support material for prototype machine
          Kelson Lachance

          I have been continuing to work on this issue; but I fear I am going down the wrong path.

           

          I am trying to get an error code when the feature does not create.  So if the feature is nothing then the error code also doesn't exist.  I am not sure if there is a method to get the warning message when the feature was attempted to be created.   If we can get this to work we should get an number for the support material as the code fails for geometric conditions and when the entire body is consumed.

           

           

          Set myfeature = swModel.FeatureManager.InsertCombineFeature(15902, Nothing, Nothing)

           
            If myfeature Is Nothing Then

           

               
                ' Get the name of the feature
                  Debug.Print myfeature.Name

                 error = myfeature.GetErrorCode2(iswarning)
                 Debug.Print "Error:          " & error

                  Debug.Print "Warning or not: " & iswarning
           
             
             swModel.ClearSelection2 True
            
             bRet = swModExt.SelectByID2("Cut" & "Step" & level & " i" & i, sBodyTypeSelStr, 0#, 0#, 0#, True, 2, Nothing, 0): Debug.Assert bRet
             Set myfeature = swModel.FeatureManager.InsertDeleteBody


          'just added
            bRet = swModExt.SelectByID2("Slice" & "Step" & level & " i" & i, sBodyTypeSelStr, 0#, 0#, 0#, True, 1, Nothing, 0): Debug.Assert bRet
            Set myfeature = swModel.FeatureManager.InsertDeleteBody


            End If