good day to all, I would like to know if there is a method that allows me to import into a sketch of an ipt the name of the file. or its "number part".
I do not believe directly but with an ilogic rule.take a look at the attached file.( e' possibile che non si possa allegare un file ipt in questo forum?!)
public sub setsketchtext(byval sketchname as string, byval strings as generic.list(of string))
dim sketch as planarsketch = findsketch(sketchname)
for each textb as textbox in sketch.textboxes
' diagnostics.trace.writeline("-- formatted text = " & textb.formattedtext)
dim newformattedtext as string = replacementformattedtext(textb.formattedtext, strings)
textb.formattedtext = newformattedtext
return
next
end sub
public function replacementformattedtext(byval formattedtext as string, byval strings as generic.list(of string)) as string
dim textlength as integer = formattedtext.length
dim k_gt as integer = formattedtext.indexof(">"c)
if (textlength < 4 orelse k_gt < 0) then
return strings(0) ' no formatting
end if
dim newformattedtext as string = string.empty
dim stringsindex as integer = 0
dim k_start as integer = 0
do
k_gt = formattedtext.indexof(">"c, k_start)
if (k_gt > 0) then
newformattedtext += formattedtext.substring(k_start, k_gt - k_start + 1)
dim k_lt as integer = formattedtext.indexof("<"c, k_gt + 1)
if (k_lt > k_gt + 1) then
if (stringsindex < strings.count) then
newformattedtext += httputility.htmlencode(strings(stringsindex))
stringsindex += 1
end if
end if
k_start = k_lt
end if
loop until k_gt < 0 orelse k_start < 0
return newformattedtext
end function
public function findsketch(byval sketchname as string) as inventor.planarsketch
dim sketches as inventor.planarsketches = nothing
dim opartdoc as inventor.partdocument
dim oassemdoc as inventor.assemblydocument
if (doc.documenttype = inventor.documenttypeenum.kpartdocumentobject) then
opartdoc = doc
sketches = opartdoc.componentdefinition.sketches
elseif (doc.documenttype = inventor.documenttypeenum.kassemblydocumentobject) then
oassemdoc = doc
sketches = oassemdoc.componentdefinition.sketches
end if
if (sketches is nothing) then return nothing
for each sketch as inventor.planarsketch in sketches
if (string.compare(sketch.name, sketchname, true) = 0) then
return sketch
end if
next
throw new argumentexception("no sketch named: " & sketchname & " was found.")