-
Re: About Macro feature .net file
Artem Taturevych Apr 29, 2013 1:18 AM (in response to Raghvendra Bhargava)Note, if you are using the .NET Framework. You should use specific interop libraries. Please read this topic: http://help.solidworks.com/2013/English/api/sldworksapiprogguide/Welcome.htm
I guess this is a reason of the fail.
____________________________________________________
Regards,
Artem Taturevych, Application Engineer at Intercad (Australia)
translationXpert – add-in to translate SolidWorks models
-
Re: About Macro feature .net file
Raghvendra Bhargava Apr 29, 2013 2:59 AM (in response to Artem Taturevych)-
Re: About Macro feature .net file
Artem Taturevych Apr 29, 2013 3:25 AM (in response to Raghvendra Bhargava)Hi Raghvendra,
Well, I assume the only thing you should change is the Post-Build action script. Please specify the paths to RegAsm v 4 in the script instead of v 2. In order to see your scrip go to Project->Properties->Build Events->Edit Post-build...
____________________________________________________
Regards,
Artem Taturevych, Application Engineer at Intercad (Australia)
translationXpert – add-in to translate SolidWorks models
-
RegAsm.png 230.1 KB
-
Re: About Macro feature .net file
Raghvendra Bhargava Apr 29, 2013 4:06 AM (in response to Artem Taturevych)Hi Artem thanks for ur reply...
But i am using Microsoft visual studio express edition 2012...and this option is not there...
-
Re: About Macro feature .net file
Artem Taturevych Apr 29, 2013 4:44 AM (in response to Raghvendra Bhargava)Try to replace your project file with the attached file.
If that doesn’t work let me know what sample project you have downloaded (there 2 VB.NET projects) and what exactly the path of your RegAsm for Framework 4.
____________________________________________________
Regards,
Artem Taturevych, Application Engineer at Intercad (Australia)
translationXpert – add-in to translate SolidWorks models
-
SwVBAddinTest.vbproj.zip 1.8 KB
-
Re: About Macro feature .net file
Raghvendra Bhargava Apr 30, 2013 4:51 AM (in response to Artem Taturevych)Hi Artem,
Thanks for your reply...
i have downloaded 'VB NET Addin InsertMacroFeature.zip'.
Anyways..i fixed all coding it is now working fine ..but now there is a problem ..please help me in this..the problem is there are three function in this ..
1)Function Edit....
2)Function Regenerate
3)Function Security...
now my aim for Macro feature is on every rebuild it should get length for one sketch segment and put in to the Custom properties ..
So this code i am putting in Function Regenerate but it is not working ..so please help me in this where i should put this code.....
-
Re: About Macro feature .net file
Artem Taturevych Apr 30, 2013 10:16 AM (in response to Raghvendra Bhargava)Is your macro feature placed before the sketch in the feature tree? When it rebuild the sketch may be rolled back if it is lower than macro feature in the tree. You may need to use the swMacroFeatureAlwaysAtEnd as InsertMacroFeature3 options parameter. Another question is how you store the pointer to the target sketch segment?
____________________________________________________
Regards,
Artem Taturevych, Application Engineer at Intercad (Australia)
translationXpert – add-in to translate SolidWorks models
-
Re: About Macro feature .net file
Raghvendra Bhargava May 2, 2013 12:30 AM (in response to Artem Taturevych)Hi Artem,
This problem is not with adding macro feature.
Problem is in code only ..see i have already created macro feature in vb(.swp) in solidworks ..so there actually in InsertMacroFeature3..we have to define methods of 9 array ...so there in one of the method i am adding my desired code ..it was like this
featmgr.InsertMacroFeature3("UpdateLength", "", (Methods), Empty, Empty, Empty, "", "", "", "", swMacroFeatureAlwaysAtEnd) ..
Above code line i have used to create .swp file ...
But in VS code is like
FeatMgr.InsertMacroFeature3("Pipe_le", "swVBAddinTest.SwAddin",Nothing,(paramNames),(paramTypes), (paramValues), Nothing, Nothing, editBody, Nothing,opts)
so here you can see..the difference..so my doubt is ....on the action of rebuild where i should write my code do desired output..
so conclusion is like if i will do rebuild in solidworks part (where macro feature is added) it should return some code to do desired action...so in .net file where i should write ...
I have downloaded 'VB NET Addin InsertMacroFeature.zip' in
https://forum.solidworks.com/docs/DOC-1396 link...
Please help me ....in this to understand...
-
Re: About Macro feature .net file
Artem Taturevych May 2, 2013 12:42 AM (in response to Raghvendra Bhargava)Hi Raghvendra,
OK, I think I understand your issue. You want to find out how to create a handler of macro feature functions in VB.NET. You are right it differs from VBA. In C#/VB.NET and C++ the com class is used as the handler of the functions.
1) In order to create the handler in VB.NET you should create a public class and implement the ISwComFeature interface which actually contains all these functions. Please note that this class should be COM visible so either enable this option on the project level in project properties or add the ComVisible attribute.
2) Pass the class id as the ProgId parameter of IFeatureManager::InsertMacroFeature3 Method. Usually this is the <Namespace>.<ClassName>. However you can explicitly assign the unique class id using the ComClass attribute. This should be the GUID of your COM-class.
3) Once you done this your macro feature is bind to this com object which is responsible for macro feature behaviour. You should implement all the logic in handler functions.
____________________________________________________
Regards,
Artem Taturevych, Application Engineer at Intercad (Australia)
translationXpert – add-in to translate SolidWorks models
-
Re: About Macro feature .net file
Raghvendra Bhargava May 2, 2013 1:13 AM (in response to Artem Taturevych)Hi Artem,
yes u got my point actually in this code IsComFeature was already added...
i have already mentioned
there are function edit,regenerate and Security..
I have checked these are like if i want to edit in macrofeature i must use edit...or on rebuld i should use Regenerate..but there is a problem..i wrote my code inside regenerate..function..but it is not working ..so am i missing something...
Function Regenerate(ByVal app As Object, ByVal modelDoc As Object, ByVal feature As Object) As Object Implements SwComFeature.Regenerate
'
Dim swmodel As ModelDoc2
Dim swfeat As Feature
Dim bret As Boolean
swmodel = Me.iSwApp.ActiveDoc
swfeat = swmodel.FirstFeatureDo While Not swfeat Is Nothing
If swfeat.Name = "ff" Then
bret = swmodel.Extension.SelectByID2("ff", "SKETCH", 0, 0, 0, False, 0, Nothing, 0)
MsgBox("Right")
End If
swfeat = swfeat.GetNextFeature
LoopMsgBox("MF Regen")
Return NothingEnd Function
but if am adding this code..Macro feature is not adding...
And if i will remove my code ..and only if i will add MsgBox("MF Regen") macro feature is adding and on rebuild it showing me message "MF Regen"....so what i am doing wrong i am not able to find...
-
Re: About Macro feature .net file
Raghvendra Bhargava May 6, 2013 1:11 AM (in response to Raghvendra Bhargava)Hi to all
Some one is having any idea about this..
-
Re: About Macro feature .net file
Artem Taturevych May 6, 2013 1:43 AM (in response to Raghvendra Bhargava)Hi Raghvendra,
Can you put the breakpoint in Regenerate to see where it fails. I wouldn’t select any objects in regenerate. Do you really need this or this just a test case? Can you attach the complete add-in for me to test?
____________________________________________________
Regards,
Artem Taturevych, Application Engineer at Intercad (Australia)
translationXpert – add-in to translate SolidWorks models
-
Re: About Macro feature .net file
Raghvendra Bhargava May 6, 2013 2:50 AM (in response to Artem Taturevych)Hi Artem,
As i have already mention i have downloaded...this macro feature from this link..
https://forum.solidworks.com/docs/DOC-1396
Three options are there i have downloaded first one...('VB NET Addin InsertMacroFeature.zip'.)
...its a class library type so i cant put breakpoint...
U plz go through this...and let me know how to put regenerate action back..through code...
-
Re: About Macro feature .net file
Artem Taturevych May 6, 2013 5:59 AM (in response to Raghvendra Bhargava)Ok, let me explain this issue. When you are passing the class name which implements the iSwComFeature interface macro feature will instantiate this class. In other words new instance of SwAddin is created. So you have two instances of the same class now: first is your add-in and second is your macro feature. When macro feature creates an instance of the SwAddin class ConnectToSw function is not raised and all variables are not instantiated.
The iSwApp is Nothing so this line throws the exception:
swmodel = Me.iSwApp.ActiveDoc
you should replace it by:
swmodel = app.ActiveDoc
where the app is the pointer to SldWorks passed as parameter to Regenerate function.
P.S. You should be able to debug add-in regardless it is class library.
____________________________________________________
Regards,
Artem Taturevych, Application Engineer at Intercad (Australia)
translationXpert – add-in to translate SolidWorks models
-
Re: About Macro feature .net file
Raghvendra Bhargava May 6, 2013 6:27 AM (in response to Artem Taturevych)Hi Artem,
Thank you so so much....for this..it was very small mistake from myside....
U are Genius man...Thanks a lot...
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
Re: About Macro feature .net file
Jacob Corder Feb 7, 2014 5:43 PM (in response to Raghvendra Bhargava)Just something to add to this discussion.
I had this same issue when i started creating my Application which uses Macro Features. What I ended up doing was putting the callback in a separate class in the same project and passed that class name to the macro feature upon creation. I had an issue where it would create a new instance of my main addin where the Callback functions were and i wanted to get the values from my current running addin so i called ISwapp.GetAddinObject(my addins class id) which worked great and connected my rebuild function with my current running application. I was then able to add lots of features at once and set a boolean to process them or wait to process all of them at once. It really helped to give me full control to the application.