So I'm quite new to the Ilogic system and my Programming skills are not very good.
Now the thing is, I want to open an Assembly and update it once I've saved the part underneath it using iLogic Rules and such. The part I'm referring to is a basic thing with a few parameters that can be changed in a pop up field I already made, once these parameters are changed I will save the part and then I want the Assembly to be automatically opened and updated. I've tried a few codes but non so far seems to work.
How will you define which assembly the part is used in?
An assembly knows which parts are used in it..
A part does NOT know which assemblies its used in.
What happens when your part is used in more than one assembly?
As far as I know It will not be used in another assembly, and I was thinking about telling it which exact document it should open. not just to tell it open assembly but open that assembly
@Anonymous,
There is no direct approach to determine the assembly from a part. Try attributes(https://modthemachine.typepad.com/my_weblog/2009/07/introduction-to-attributes.html) or custom iProperties which can store assembly name of part used in.
Thanks and regards,
If the assembly has either been initialized (but not fully open) or fully open (but in the background), you could use the part documents' (oPDoc.ReferencingDocuments property to get all in-memory documents that are referencing the active part. Then loop through them, checking if it is an assembly, to get that document, then open or activate it. Then you can also update it and save it, if you want.
Otherwise, to simply open the assembly, with a supplied full file name, you can use something like this:
Dim oADoc As AssemblyDocument = ThisApplication.Documents.Open(oAssemblyFullFileName,True) 'True = visibly, False = in the background
Wesley Crihfield
(Not an Autodesk Employee)
You can access referencing documents of a part, which should have all assemblies/drawings/derived parts that reference the Part. You would need to eliminate any non-assembly files and if there is more than 1 left, specify which of them is the true parent. [maybe with a input-listbox for user interaction]
Code below is a proof of concept, hard-coded for the first referencing document, and will have more possibilities if the part is used by multiple documents:
Dim pDoc As PartDocument = ThisDoc.Document
MessageBox.Show("Referencing documents: " & pDoc.ReferencingDocuments.Count & " Item 1: " & pDoc.ReferencingDocuments.Item(1).DisplayName, "Placed Inside Assembly:")
Let me know if something doesn't make sense or if this is not what you are looking for.
Can't find what you're looking for? Ask the community or share your knowledge.