Jump to content

How to change element id in a saved template (.tpl)

Recommended Posts



I have a saved templete which generates a graph between stress vs strain for a given element id i.e. E181115 (in my case). The graph can be seen in attchments.

#Now i want to change the element id or write a tcl code in such a way that it should ask me to enter the element id before running my template. 

I am very new to hyperview and have no idea how to covert .tpl to .tcl,

Any answers, suggestions could be very much helpful. 

I am also attching my .tpl file (for understanding)


Thanks in advance





Share this post

Link to post
Share on other sites


Native way to modify a text file:

#open that template file:

set fpt [open $TplFilePath r]

#read file and search for elemID

set Content [read -nonewline $fpt]

set Index [string first $elemID $Content]

#replace elemID

close $fpt; set fpt [open $TplFilePath w]

set NewContent [string replace $Content $Index [expr $Index+[string len $elemID]] $NewElemID]

puts $fpt $NewContent

close $fpt


I think tpl functions can help to select elemID. But I can't remember how to do :(

Share this post

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

You are posting as a guest. If you have an account, please sign in.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...