-
Re: FeatureExtrusion3 fails when added in loops
Nilesh Patel Jul 21, 2017 7:40 AM (in response to Rahul Khande)Hi Rahul,
I have created a macro from your codes and works fine for me. Below are the codes.
Option Explicit Sub main() Dim swApp As SldWorks.SldWorks Dim swModel As SldWorks.ModelDoc2 Dim swFeatMgr As SldWorks.FeatureManager Dim swFeat As SldWorks.Feature Dim i As Integer Set swApp = Application.SldWorks Set swModel = swApp.ActiveDoc Set swFeatMgr = swModel.FeatureManager For i = 1 To 4 swModel.Extension.SelectByID2 "Sketch" & i, "SKETCH", 0, 0, 0, True, 0, Nothing, 0 Set swFeat = swFeatMgr.FeatureExtrusion3(True, False, True, swEndConditions_e.swEndCondThroughAll, swEndConditions_e.swEndCondThroughAll, 0, 0, _ False, False, False, False, 0, 0, False, False, False, False, True, True, False, _ swStartConditions_e.swStartSketchPlane, 0, False) Next i swModel.ClearSelection2 True End Sub
Here are before the macro and after the macro screenshots.
Before the macro:
After the macro:
I guess you are using SW2016 or SW2017 whereas I am still using SW2015, so even if you attach your part here, I won'e be able to open it.
Good luck.
Regards,
-
Re: FeatureExtrusion3 fails when added in loops
Rahul Khande Jul 26, 2017 6:37 AM (in response to Nilesh Patel)Thank you Nilesh.
Your suggestion worked for me in scenario explained below:1. Create a sketch for e.g. Sketch1.
2. Start the iteration.
3. Select "Sketch1" and extrude
4. Continue extrude on "Sketch1" for required number of extrude iterations.Now, I have a different sketch, in each iteration, new sketch is created at different location in same part file.
My new scenario is
1. Start the iteration.
2. Create a sketch for e.g. Sketch1 or Sketch at index.
3. Select respective Sketch for e.g. for iteration 1 select "Sketch1" and extrude4. Extrude on "Sketch1".
5. Start next iteration
In my above explained scenario, extrusion fails.Can you please check for above second scenario.
-
Re: FeatureExtrusion3 fails when added in loops
Nilesh Patel Jul 26, 2017 5:40 PM (in response to Rahul Khande)Hi Rahul,
Code I posted doesn't create 4 extrusions for same sketch (e.g. Sketch1) but it selects Sketch1 and creates extrusion for Sketch1. Then selects Sketch2 and creates extrusion for Sketch2. Runs this loop for all 4 sketches in my model. This the scenario you are looking for.
-
Re: FeatureExtrusion3 fails when added in loops
Rahul Khande Jul 28, 2017 7:58 AM (in response to Nilesh Patel)Thank you Nilesh.
I could reproduce the issue in new template project:
Attached is my code :Please follow the steps below:
1. Unzip the attached zip file.
2. Launch the project in Visual Studio 2012.
3. Run the application i.e. SolidWorks will run.
4. Click on C# Plugin tab => "Create Cube"
5. Check the output.
In case you are not able to build, I have attached a text file containing my functions:Start point of execution is : CreateCube()
Please review the same and share your suggestions.
-
SW C# Plugin.zip 148.9 KB
-
Re: FeatureExtrusion3 fails when added in loops
Nilesh Patel Jul 29, 2017 11:05 PM (in response to Rahul Khande)Hi Rahul,
I ran your codes.
1. You create a sketch and then extrude the same sketch.
2. You then move the body to a location (X= 0.8593, Y= 0.4063).
3. You repeat these steps 5 times (creating a sketch at same location and same shape and moving the body at same location).
I ended up with 5 extruded bodies (all same in size and shape) and moved to same location which looked like one body. I didn't run into any trouble. But this doesn't tell me what is your problem or what you would like to achieve. I am sure you don't want to create 5 identical bodies moved to a same location.
Could you explain more about what is your end goal is?
Regards,
-
-
-