I have a macro that adds a "Nom_Modificateur" property in a part, The problem is that when I open my layout (still in the macro) the background does not change, I am forced to edit the background plan then explode the block and the my given appears. To know if from the beginning I burst the block, the macro works perfectly. But I don't want to break the block because I have another macro that also writes cleanliness that is in the cartridge and that works while the code is identical.
Here's the code:
Set Part = swApp.OpenDoc6(File, 1, 0, "", longstatus, longwarnings) Set swApp = Application.SldWorks 'We get the active document Set swModel = swApp.ActiveDoc
Complicated to work with so little give, can you put the code of your other macro? When you launch the other one you are already on the drawing, or does it also open a document?
I have several .slddrt plan formats(A4H, A4V, A3H...) All of these formats have a block link to a block file to define everything that should be in the title block (.sldblk file). Thanks to this, if I want to add an element I add it to the sldblk file and all my formats are modified. It's better than editing on all plan formats (I'm 30)
So if my basemap has an exploded block, will I lose the link?
Do you really have to break up the block for the changes to be taken into account or is a simple reconstruction enough?
For your information, the changes made by macro quite often require a reconstruction to be taken into account, it's the famous CTRL + Q which is a bit of a reflex.
The macro cannot work with the block because the block is write-protected unless you add a box directly to the modifier name and populate in a property of the part.
That's exactly what I do, I add a personal property to my 3d file and in my cartridge I have the name of this property which are the same. But my problem is that it doesn't show up. And even if I explode my block beforehand, I still have to edit the background plan for it to appear
As ac cobra says, the variable doesn't seem to exist so your code would have to match this:
swCustPropMgr.Add3 "Type_Validation", swCustomInfoText, "", 0 swCustPropMgr.Add3 "Date_Validation", swCustomInfoText, "", 0 swCustPropMgr.Add3 "Index", swCustomInfoText string, 0 If string = "02" Then
...
On the link below you see that the variables must exist if you put a "2" at the end, it replaces the value only if the latter exists. With a 0 it creates the variable if it is non-existent.
On the other hand, be careful you have to plan an increment when going, otherwise the first time you use it will create the A02 - A03 .... and the next time you use them, since they are already created, he won't do anything. and if you put "1" it will rewrite on it each time so you won't have a history anymore.
I solved my problem. During the first macro that inserts data I put all my future index values and I don't know why, when it has already created a value, the second time it does the update by itself.
Thank you for all your answers, I know that not everything is clear...