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

change reference to a derived part

  • Thread starter Thread starter MANFRUK
  • Start date Start date

MANFRUK

Guest
Good morning to all,
I have a question to ask you, as a result of changes I need to change the part that gives me a derived part.
do you know a clear and simple procedure to do so? I found in several sites of programming from ilogics, but it doesn't seem very fast.
Thank you.
 
in the title you say:
-change reference. .
in the post
-change the part of origin.

for the first, if you intend to replace one part of origin with another, it seems to me that you do not accept replacement.
for the second, you can change what you want,... I don't understand the ilogic.
Maybe you could better describe what you want to do... .
 
It seems to me that you do not accept replacement
from the browser, temporarily rename the father file, open the son file, which looks for the father and make it point to the stepfather.
then, restore the father's name.
It's the same thing that he did. makes to point a table to a similar model, in an attempt to partially recover the work done.
they took some time to understand that it would be a useful command and, finally, they gave birth to the "model reference substitution ".
among some rel. will also put the " replace reference model " for the particular derivatives, hopefully.
 
il comando ilogic c'è , funziona perfettamente ed è molto veloce
personalmente lo utilizzo da parecchi anni

non ricordo più da dove l'ho scaricato ma, lo allego sotto

saluti

option strict on

sub main
topdoc = thisdoc.document
replace()
end sub

private topdoc as document

public sub replace()
if (not levelofdetailismaster()) then return

dim doctoreplace as document = finddoctoreplace()
if (doctoreplace is nothing) then return

dim replacementfilename as string = selectreplacementfilename(doctoreplace.displayname)
if (string.isnullorempty(replacementfilename)) then return
if (string.equals(doctoreplace.fullfilename, replacementfilename, stringcomparison.ordinalignorecase)) then return

dim replacementpart as document = thisapplication.documents.open(replacementfilename, false)
dim doreplace as boolean = true
if (replacementpart.internalname <> doctoreplace.internalname) then
messagebox.show("la parte sostituta (" & replacementpart.displayname & ") non sembra essere strettamente legato alla parte originale, quindi non può essere utilizzato.", _
"base part replacer", messageboxbuttons.ok, messageboxicon.warning)
doreplace = false
end if
replacementpart.releasereference()

if (not doreplace) then return

dim filenametoreplace as string = doctoreplace.fullfilename
replacereferences(topdoc, filenametoreplace, replacementfilename)
topdoc.update()
end sub

function finddoctoreplace() as document
dim basepartlist as new list(of document)
if (topdoc.documenttype = documenttypeenum.kpartdocumentobject) then
addbaseparts(basepartlist, topdoc)
else
for each refdoc as inventor.document in topdoc.allreferenceddocuments
if (refdoc.documenttype = documenttypeenum.kpartdocumentobject) then
addbaseparts(basepartlist, refdoc)
end if
next
end if
if (basepartlist.count = 0) then
messagebox.show("no base parts were found in the document: " & topdoc.displayname, "base part replacer")
elseif (basepartlist.count = 1) then
return basepartlist(0)
else
dim partnamelist as new list(of string)
for each basedoc as document in basepartlist
partnamelist.add(basedoc.displayname)
next
dim selectedname as string = inputlistbox("seleziona la parte da rimpiazzare", partnamelist, partnamelist(0), "rimpiazzo", "parts").tostring()
dim selectedindex as integer = partnamelist.indexof(selectedname)
return basepartlist(selectedindex)
end if
return nothing
end function

sub addbaseparts(byval basepartlist as list(of document), byval doc as document)
for each refdoc as document in doc.referenceddocuments
if (refdoc.documenttype = documenttypeenum.kpartdocumentobject andalso not isipartmember(refdoc)) then
if (not basepartlist.contains(refdoc)) then
basepartlist.add(refdoc)
end if
end if
next
end sub

function isipartmember(byval doc as document) as boolean
if (doc.documenttype <> documenttypeenum.kpartdocumentobject) then return false
dim partdoc as partdocument = directcast(doc, partdocument)
return partdoc.componentdefinition.isipartmember
end function

function selectreplacementfilename(byval filenametoreplace as string) as string
dim ofiledlg as inventor.filedialog = nothing
thisapplication.createfiledialog(ofiledlg)
ofiledlg.filter = "part files (*.ipt)|*.ipt"
ofiledlg.dialogtitle = "rimpiazzo " & filenametoreplace & " con il file...."
'ofiledlg.initialdirectory = thisdoc.path
ofiledlg.cancelerror = false
try
ofiledlg.showopen()
return ofiledlg.filename
catch
end try
return string.empty
end function

sub replacereferences(byval doc as document, byval filenametoreplace as string, byval replacementfilename as string)
replacereferencesinonedoc(doc, filenametoreplace, replacementfilename)

for each subdoc as document in doc.allreferenceddocuments
if (string.equals(subdoc.fullfilename, filenametoreplace, stringcomparison.ordinalignorecase) orelse _
string.equals(subdoc.fullfilename, replacementfilename, stringcomparison.ordinalignorecase)) then
continue for
end if
replacereferencesinonedoc(subdoc, filenametoreplace, replacementfilename)
next
end sub

sub replacereferencesinonedoc(byval doc as document, byval filenametoreplace as string, byval replacementfilename as string)
for each docdesc as documentdescriptor in doc.referenceddocumentdescriptors
dim desc as filedescriptor = docdesc.referencedfiledescriptor
if (desc.referencemissing) then continue for
console.writeline("referenced relativefilename = " & desc.relativefilename)
trace.writeline("referenced relativefilename = " & desc.relativefilename)
if (string.equals(desc.fullfilename, filenametoreplace, stringcomparison.ordinalignorecase)) then
desc.replacereference(replacementfilename)
exit for
end if
next
end sub

function levelofdetailismaster() as boolean
dim assemdoc as assemblydocument = trycast(topdoc, assemblydocument)
if (assemdoc is nothing) then return true

dim repmgr as representationsmanager = assemdoc.componentdefinition.representationsmanager

dim lodtype as levelofdetailenum = repmgr.activelevelofdetailrepresentation.levelofdetail
if (lodtype <> levelofdetailenum.kmasterlevelofdetail) then
messagebox.show("this rule can only be run in the master level of detail.", "base part replacer")
return false
end if
return true
end function
 
from the browser, temporarily rename the father file, open the son file, which looks for the father and make it point to the stepfather.
then, restore the father's name.
It's the same thing that he did. makes to point a table to a similar model, in an attempt to partially recover the work done.
they took some time to understand that it would be a useful command and, finally, they gave birth to the "model reference substitution ".
among some rel. will also put the " replace reference model " for the particular derivatives, hopefully.
It doesn't always work. .
If I make an ex novo stepfather, it doesn't work.:confused:
it only works if the stepfather is a copy of the father and if there were no changes that overwhelmed the order of the work.
otherwise the writing comes out that "patrigno has been solved with father, which however is not the original reference file. impossible to solve the link"...:mad:
 

Forum statistics

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

Members online

No members online now.
Back
Top