Make a watermark appear in the basemap

Hello

 

I'm working in solidworks 2011, I already have a macro that saves me my active plan, the plan of my active part or all the plans of the active assembly, all in the right location.

This macro simply uses the "save as" function in PDF format from solidworks (no virtual printers such as Bullzip or PDFcréator!)


My problem is that I would like to make a text appear in my basemap with "FOR CONSULTATION" written if I want to when launching my PDF macro.

 

First of all, I thought of creating an angled block with the right font, the right size, and I tried to add it to my background by macro. The problem is that, since there are several plan formats to different formats, the inserted block position as well as the size is not the easiest to manage.

I then thought of simply making a note on my basemap (already well positioned and at the right size) and simply having it displayed and then hidden when running my macro if I decide that this version of the plan will be only for consultation.

With a recording I manage to hide my text box:
 

Sub main()

Set swApp = _
Application.SldWorks

Set Part = swApp.ActiveDoc
boolstatus = Part.Extension.SelectByID2("Plan détail1988@Fond object", "NOTE", 0.2884716463644, 0.1501347778362, 0, False, 0, Nothing, 0)

Part.HideDimension


End Sub

It works well and this piece of code gives me the ID of my text box at the same time. This allows me to write another piece of code to reselect my note.
On the other hand, no matter how hard I look, I can't find the function that allows me to redisplay this note!!!!

The selection of the note leads me to another question:

How do I control the ID of an object? because depending on my different baselines, the ID of my note will probably not always be the same (Object of détail1988@Fond of plan" in my example above)

Sorry, I may be asking basic questions in VBA SolidWorks but I've been doing them for a very short time.

Thanks in advance!

Yves

 

Hello

The easiest way is to give it a name when it is created.

It is thus much easier to find it later, with this instruction:

http://help.solidworks.com/2012/English/api/sldworksapi/Get_Note_By_Name_Example_VB.htm

Edit: a page that could be interesting in addition:

http://help.solidworks.com/2013/English/api/sldworksapi/Place_Note_Behind_Drawing_Sheet_Example_VB.htm

 

 

I often do this to send to the customer.

 

I created a special background with a very light layer on it where I wrote the name of the company in large letters.

 

Then afterwards during a drawing, either I choose directly the basemap where this filligrane is located, or I go through a macro that changes my current background to put the filligrane.

 

View image


filligrane.png
1 Like

See this video link

https://www.youtube.com/watch?v=R87mZoshW_Y

@+

Thank you for your answers

 

.PL: I can't use macros on your links

 

Bart: It's true that it's an idea that can also remove another problem for me!
 

I'll try like this.

 

Yves

 

I save a lot of time with that.

 

Especially when I change my backgrounds for who knows what reason.

To open the old mep with the new basemaps, it's magic!^^

You don't even need to type code in vba. You just have to do the manipulation by hand by clicking on save marco and then stop at the end of the manipulation.

Then insert the shortcut buttons and forward guinguamp^^

(Benoit, is it better that way?) =)


rectif.png
1 Like

 

Bart: I answered too quickly, I can't use the technique of changing the background because I add elements in my background plan such as the index evolution table for example and all these elements would jump each time.

GT22: Thank you for this video. But my problem is still the same. How do I display my note that is hidden in my basemap?

 

@yves: Why can't you use macro? Of course, the code must be adapted.

In addition, the code I gave is to find a note by name, you have to name it at the creation!

I'd like to use the macro but what do you call your note when it is created?

 

@Lucas: The hospital that doesn't give a damn about charity...^^

 

@yves: For your macro, logically, your notes and tables should not be jumped on they are anchored on your sheet.

2 Likes

.PL : I create it manually with the "grade" tool in the "rating" tab

The macro in question tells me an error on "loop" by telling me

          Compilation error:
          Loop without C

Bart: My elements jump every time I change the baseplane because I constrain them in relation to the elements of my basemap

Why were all my off-topic answers deleted?

1 Like

I don't know, but all this doesn't answer my question of naming a note when it was created or changing its name afterwards. Then to make a hidden note appear...

 

Thank you

 

Yves

1 Like

Yves: Could you create a macro by learning when creating the note, so that I can see the code please?

Hello .PL

 

Here is the record of how the note was created:

 

Sub main()

Set swApp = _
Application.SldWorks

Set Part = swApp.ActiveDoc

Dim myNote As Object
Dim myAnnotation As Object
Dim myTextFormat As Object
Set myNote = Part.InsertNote("PONR CONSULTASION")

If Not myNote Is Nothing Then
   myNote.Angle = 0
   boolstatus = myNote.SetBalloon(0, 0)
   Set myAnnotation = myNote.GetAnnotation()
   If not myAnnotation is nothing then
      longstatus = myAnnotation.SetLeader3(swLeaderStyle_e.swNO_LEADER, 0, True, False, False, True)
      boolstatus = myAnnotation.SetPosition(0.1631152186896, 0.1620775367073, 0)
      boolstatus = myAnnotation.SetTextFormat(0, True, myTextFormat)
   End If
End If

Part.ClearSelection2 True
Part.WindowRedraw

End Sub
 

For more readability, I attach the text file

 

Yves

 


macro_creation_note.txt

In fact instead of creating the note by hand, it will be possible to create it with a macro each time, is it a problem?

I didn't understand that the note was created manually at the beginning.

Edit: if not, is the text still "FOR CONSULTATION" exactly ?

In fact, as I said in my initial post, I had actually thought of creating it and then deleting it each time. The problem is that I have the 4 possible background formats (A3, A2, A1 and  A0) which means that the size of the note must adapt each time as well as its position.

That's why I liked the idea of having already created it but hidden. 
I just needed the possibility to impose the ID of this note (so that in all my basemaps they all have the same one) and the code to show it (since I already have the line of code to hide it)

Hello 

 

So there is no line of code to display a note that is hidden? when there is one to hide a visible note?

 

Thank you

 

Yves

Hello, I confirm that we save a lot more time because we don't have to bother to type the codes in Vba anymore. It's very convenient.