Embedding the File Name in Property Editor

Hello

I want to add the name of the file preceded by its path in the property window?

Today I manage to recover the name with:

<Control Label="FileName" PropName="Textbox19" ApplyTo="Global" Type="TextBox" ReadOnly="False" DefaultValue="SW-File Name" Mode="SWProperty" />

On the other hand I tried a lot of variable names  such as "Folder Name" ... but I can't do it.

Thank you.

A+

Edit; I succeeded by putting a high dash:

<Control Label="PATH" PropName="Path" ApplyTo="Global" Type="TextBox" ReadOnly="False" DefaultValue="SW-Folder Name" Mode="SWProperty" />

On the other hand I can't concatenate the 2?

 

Hello 

Do you absolutely want to have the file path in the properties, or would having this information in an annotation (for a drawing) be enough?

For the moment except with a macro, I don't see how to add this info in the properties. However, if you want the macro:

Option Explicit

Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim config As SldWorks.Configuration
Dim cusPropMgr As SldWorks.CustomPropertyManager
Dim custPropType As Long
Dim FieldType As Integer
Dim customProp As CustomPropertyManager
Dim PathPlan As String


Sub main()
    FieldType = 30
    Set swApp = Application.SldWorks
    Set swModel = swApp.ActiveDoc
    Set config = swModel.GetActiveConfiguration
    Dim swCustProp As CustomPropertyManager
    Dim swModelDocExt As ModelDocExtension
    Dim bool As Boolean
    Set swModelDocExt = swModel.Extension
    Set swCustProp = swModelDocExt.CustomPropertyManager("")
    PathPlan = swModel.GetPathName
    bool = swCustProp.Add3("Chemin Fichier", FieldType, PathPlan, swCustomPropertyAddOption_e.swCustomPropertyDeleteAndAdd)
End Sub

 

Alternatively, to add this info to a note in a drawing, you can link a property to a note. (See pj)

 


ajoutpathdansnote.png

Hello

Thanks for the answer, but no I need to re-edit it to put it in an attribute only that will contain "path/name".

I can't find the list of variables or properties that can be used?

Do you know if you can concatenate fields?

A+

Hello

Why not use the "SmartProperties" tool from myCADtools? This tool allows, among other things, to concatenate property values (a feature that the SW property editor does not allow).

Kind regards

It's okay I found it, 

Put this in the value of your property:

$PRP:"SW-Folder Name(Folder Name)"$PRP:"SW-File Name(Folder Name)"

Super.... except that I have to make a wrong move and it doesn't work.

Below is what I typed.

<Control Label="PATH" PropName="Path" ApplyTo="Global" Type="TextBox" ReadOnly="False" DefaultValue="$PRP:"SW-Folder Name(Folder Name)"$PRP:"SW-File Name(Folder Name)"" Mode="SWProperty" />

Or am I wrong?

Thank you.

Hello

Try this: 

$PRP:{SW-Folder Name}

 

Dsl I made a mistake, I forgot MODEL in the order!!

 

$PRPMODEL:"SW-Folder Name"

Once the code is pasted into your property editor, the path and name will appear in the MEP automatically.

Just type what I gave you in the value of your property:

$PRP:"SW-Folder Name(Folder Name)"$PRP:"SW-File Name(Folder Name)"

(See pj)


proprietepath.png

Hello

Replace your line:

<Control Label="PATH" PropName="Path" ApplyTo="Global" Type="TextBox" ReadOnly="False" DefaultValue="SW-Folder Name" Mode="SWProperty" />

By:

<Control Label="PATH" PropName="Path" ApplyTo="Global" Type="TextBox" ReadOnly="False" DefaultValue="SW-Folder Name"$PRP:" SW-File Name" Mode="SWProperty" />

Kind regards

2 Likes

Hello

A big thank you, it works perfectly.

A+

Hello

Just one last little question where do we  find the names of available variables as well as the "grammar".

Is it possible to put a default value in a ComboBox?

Or does it follow the rules of a particular language, a priori XML?

Because to see, I tried to replace the "" " with double quotation marks and it didn't work anymore...?

Thank you

A+

Hello

It is precisely because quotation marks do not work that we should put " Instead, and this is true for all text that includes quotation marks in the attribute value in XML files, which is the case with the .prtprp file, quotation marks are used to surround attributes.

Kind regards

A priori, no default value is possible on comboboxes.

And for the list of properties, see here.

Kind regards

Hello

Thank you for this information, but I'm surprised, in the listing of properties I have the impression that you can enter the names of properties either in English or in French...?

I have one last small problem, I would like to display the name of the file with its ".sldprt" extension, but I can't find the right syntax....?

Thank you.

A+

Hello

I haven't tested for English or French, for my part I haven't used the property palettes for a long time but at the time it was systematically in English.

For the addition of the extension, I couldn't find a corresponding property but it is possible by creating a text property that contains the desired value according to the loaded property palette (.prtprp or .asmprp file) and then concatenating it with the SW properties as in the example below:

<GroupBox Label="Zone de groupe" PropName="Zone de groupe2" DefaultState="Expanded">
<Control Label="Extension" PropName="Extension" ApplyTo="Config" Type="TextBox" DefaultValue=".sldprt" Mode="text" />
<Control Label="Nom Complet" PropName="NomComplet" ApplyTo="Config" Type="TextBox" DefaultValue="SW-Folder Name&quot;$PRP:&quot;SW-File Name&quot;$PRP:&quot;Extension" Mode="SWProperty" />
</GroupBox>

Kind regards

Hello

Sorry it doesn't work as if it doesn't consider "extension" a system variable.

How to do it?

Another question, what is another solution for filling in the § attributes?

Today we work with an "in-house" macro, in which we fill in the attributes, on the other hand, we have to open the part or assembly we want to fill.

For this reason, the property palette seemed interesting because it allowed the part attributes to be filled in directly in the assembly (comfort)...

Thank you.

A+

Hello

Weird that it doesn't work:

Opening the palette and before clicking on "Apply":

The calculation is not made.

After clicking on "Apply":

The calculation was done well.

Test done by opening the part in SW and also directly by editing the part in the assembly.

Did you put Mode="Text" at the end of the line that defines the "Extension" property?

To the question " what is another solution for filling in the § attributes? ", it's by a homemade program in which I manage SW properties and many other things.

Kind regards