• This forum is the machine-generated translation of www.cad3d.it/forum1 - the Italian design community. Several terms are not translated correctly.

10 digit file name extraction

telegino

Guest
Hello everyone,

I would have a request for the properties to be included in the draft.
in practice I would need the file name (without extension), but only truncated
in the last 10 digits, otherwise a very long string appears to me (because
some files have a very long name).
I looked in the old posts, but I couldn't find anything.

Thank you.
 
Okay.

thanks to the answer, I read the link with the change
of the property of the text, but there is not what I seek.

Hi.
 
According to me you could create a custom property by setting it with a macro that plays with the "substring" function. . .
 
I did some tests by modifying one of samples that there is in the cd of solid edge (solidedge.propertysets)
first of all I added two variables with the first referring to the file name of the active document
Code:
dim strnomefile as string = nothing
dim strnomefilebreve as string = nothing
strnomefile = ctype(application.activedocument.name(), string) ' ad esempio "codparte - descrizioneparte - 00.psm"
then I valued litter files passing it as a sub parameter addcustomproperties
Code:
strnomefilebreve = strnomefile.substring(0, 8) ' extracts the first eight characters of the file name = codparte
'or
'strnomefilebreve = strnomefile.substring(0, strnomefile.length - 4)' extracts file name without extension = codparte - descriptionpart - 00
'strnomefilebreve = strnomefile.substring(11, strnomefile.length - 20)' extracts the central part of the file name from pos.12 to pos.(length - 9) = part description
'strnomefilebreve = strnomefile.substring(strnomefile.length - 4 - 2, 2)' extracts the last two characters of the file name = 00

...

addcustomproperties(propertysets, strnomefilebreve)
so I changed the same addcustomproperties to accept the parameter and to add it to the property list
Code:
    private shared sub addcustomproperties(byval propertysets as solidedgeframework.propertysets, byval strnomefilebreve as string)
        dim properties as solidedgeframework.properties = nothing

        properties = propertysets.item("custom")

        console.writeline("aggiungo le mie prorietà personalizzate.")

        properties.add("codparte", strnomefilebreve)
        'properties.add("desparte", strnomefilebreve(2)
        'roperties.add("revparte", strnomefilebreve(3))
        'properties.add("my integer", 338)
        'properties.add("my boolean", true)
        'properties.add("my datetime", date.now)
    end sub
at this point, if the active document is a dft add to the cartilage a recall (or another annotation that supports the property text) that refers to the newly added property (%{codparte/cp}), otherwise, if the active document was a 3d, to the folder of his drawing the annotation will refer to the property of the part itself (%{codparte/cp|r1}))

I hope to have been clear and helpful

Hi.
 
before proceeding with the most diverse solutions I would question the fact of memorizing in the filename important data such as code and description.

Hi.
 
before proceeding with the most diverse solutions I would question the fact of memorizing in the filename important data such as code and description.

Hi.
.. of course everyone calls his files as best he thinks;
I certainly did not want to "impose" anything, but only to propose to telegino a "aseptic" solution to his question that, in my little one, I managed to invent: if its file is called "abcdefghijkllmnopqrstuvwxyz-1234567890.ext" and in the cartiglio wants to display only the last 10 characters (excluding extension and separator point), then the instruction to do this will be
Code:
strnome files = strnomefile.substring(strnomefile.length - 4 - 10, 10)

ciao
 
.. of course everyone calls his files as best he thinks;
I certainly did not want to "impose" anything, but only to propose to telegino a "aseptic" solution to his question that, in my little one, I managed to invent: if its file is called "abcdefghijkllmnopqrstuvwxyz-1234567890.ext" and in the cartiglio wants to display only the last 10 characters (excluding extension and separator point), then the instruction to do this will be
Code:
strnome files = strnomefile.substring(strnomefile.length - 4 - 10, 10)

ciao
I do not have it against your solution, I just wanted to make it clear that it is good to use the file name for what it is, that is the file name.
go to store important data in such place is the best way to mess up an unmanaged archive.
before doing too much damage my advice is to start calling files with a better criterion, which mainly helps storage.
when working without a management it is important to organize things well.

said this one is very free to do as he seems so much then the damage if he keeps them (or the wrongdoing that in the future replaces it:biggrin:)

Hi.
 

Forum statistics

Threads
44,997
Messages
339,767
Members
4
Latest member
ibt

Members online

No members online now.
Back
Top