9 Replies Latest reply on Feb 14, 2014 8:28 PM by Simon Turner

    Is there a SW expert watching over the posts

    Tony Hong

      I am just wondering if there is a SW expert that can give correct answers to the questions posted on this forum?

        • Re: Is there a SW expert watching over the posts
          J. Mather

          I have seen a lot of Certified SolidWorks Experts (and Professionals, and others) watch over questions posted on this forum and provide correct answers.  Just look at the number of answers that were accepted by the original OPs asking the quesions.

           

          Do you have a specific thread  in mind (provide url)?

            • Re: Is there a SW expert watching over the posts
              Tony Hong

              I have been struggling with the following questions for days, but still can't solve them...

               

              https://forum.solidworks.com/message/410224#410224

              https://forum.solidworks.com/message/410130#410130

               

              Thanks

                • Re: Is there a SW expert watching over the posts
                  Simon Turner

                  I think Artem made some sensible suggestions.

                  Also, for your weldment profile point, I noticed this code:

                   

                  boolstatus = swDoc.Extension.SelectByID2("Point27@Sketch11", "EXTSKETCHPOINT", 0, 0.20332700000000004, 0, true, 0, null, 0);

                  boolstatus = swDoc.Extension.SelectByID2("Point27@Sketch11", "EXTSKETCHPOINT", 0, 0.20332700000000004, 0, true, 0, null, 0);

                   

                  So, you are selecting the same point twice - therefore deselecting it.

                   

                  For your second point, you didn't really give enough information to say more than Artem already said. You have to check the status of swDoc as soon as you create the new document. Check that it really is creating the file.

                    • Re: Is there a SW expert watching over the posts
                      Tony Hong

                      Hi Simon,

                       

                      Actually, it doens' matter how many times the point is selected. The selection function SelectByID2 returns "false" everytime. I don't know the reason.

                       

                      I created a c# marco, and the same line doesn't work either...

                       

                      Tony

                        • Re: Is there a SW expert watching over the posts
                          Simon Turner

                          I wonder - you are effectively editing a feature when you use swWeldFeatData.AccessSelections

                          Maybe if you get the sketchpoint before calling AccessSelections it may work.

                            • Re: Is there a SW expert watching over the posts
                              Tony Hong

                              I created a c# macro by recording the modeling process - first generate a structural beam, then change the profile location point. With this macro, a beam is created automatically, but the profile is by default located at the center point, not the point I specified.

                               

                              I debug the macro project, the line which is samiliar to the one I developed in my program,

                               

                              boolstatus = swDoc.Extension.SelectByID2("Point27@Sketch11", "EXTSKETCHPOINT", 0, 0.20332700000000004, 0, true, 0, null, 0);

                               

                              returns "false" too.

                               

                              I didn't change anything after the macro project is created.

                               

                              I wonder if SW has a bug there...

                                • Re: Is there a SW expert watching over the posts
                                  Simon Turner

                                  I personally wouldn't select the point by name. Also, I don't think you actually need to select the point. You just need to get it from the list of sketch points returned by Sketch::GetSketchPoints2

                                   

                                  Here is a VBA macro which gets a sketch point from a sketch, given the known X and Y coordinates:

                                   

                                  Option Explicit

                                   

                                  Dim swApp As SldWorks.SldWorks

                                   

                                  Dim Part As ModelDoc2

                                  Dim mySketch As Sketch

                                   

                                  Dim boolstatus As Boolean

                                  Dim longstatus As Long, longwarnings As Long

                                   

                                  Sub main()

                                      Dim myPart As PartDoc

                                      Dim myFeat As Feature

                                      Dim mySketch As Sketch

                                      Dim myPoints As Variant

                                      Dim myPt As SketchPoint

                                      Dim i As Integer

                                      Dim mX As Double, mY As Double

                                     

                                      'Coordinates of desired point

                                      mX = 15 / 1000

                                      mY = 25 / 1000

                                     

                                      Set swApp = Application.SldWorks

                                      Set Part = swApp.ActiveDoc

                                      Set myPart = Part

                                      Set myFeat = myPart.FeatureByName("Sketch1") 'Or whatever your sketch is called (or use some other method of getting to the sketch - traverse the sub-features of your structural member)

                                      Set mySketch = myFeat.GetSpecificFeature2

                                      myPoints = mySketch.GetSketchPoints2

                                      For i = 0 To UBound(myPoints)

                                          Set myPt = myPoints(i)

                                          If Abs(myPt.X - mX) < 0.00001 And Abs(myPt.Y < mY) < 0.00001 Then 'This must be the point

                                              Exit For

                                          End If

                                      Next

                                     

                                      boolstatus = myPt.Select4(False, Nothing)

                                   

                                  End Sub

                            • Re: Is there a SW expert watching over the posts
                              Tony Hong

                              Regarding the second question, the add-in works well when SW is run directly, not called from Visual studio. When I debug the program in VS, swDoc returns null, and the error info pops up.

                        • Re: Is there a SW expert watching over the posts
                          Tim Webb

                          Agreed Tony

                           

                          I've been struggling with the issue on this thread

                          https://forum.solidworks.com/thread/77758?tstart=0

                           

                          But unfortunately the thread has received little attention. It is completely API related but is EPDM API so it did not make sense to post it in the EPDM area.

                           

                          Anyway, yeah, I agree.

                           

                          Tim Certified Enterprise PDM Administrator

                          equivaQ Software, LLC

                          http://www.equivaq.com