First off, newbie speaking here. I've searched around and surprisingly can't find a straightforward answer to my simple question below.
About to write my first iLogic code in a drawing. Before I get too deep I have an initial question. How do you "stabilize" the drawing's associated model so that the code will still work regardless of the model's name? This drawing will be copied (CopyDesign) along with the model. The model iLogic code will work because I've "stabilized" the browser nodes but that doesn't seem to work in drawings. I intend to have some drawing code that grabs info (parameters, iProps) from the assembly model so a stable connection between the drawing and model regardless of model name is essential.
I'm going to guess that I have to use additional code provided in iLogic to GET the model document name (code available under "Advanced Drawing API" and go from there. To do this do I have to incorporate a VBA "Dim" statement to hold the model name value or set it as a custom iProp in the drawing?
What I'm mainly looking to do is get the model info into the drawing where I can run some simple If/Then statements to manipulate the data as needed for the drawing. Just looking for some help to kick me off in the right direction when working with iLogic in drawings.
Thanks.
MechMan
Hi,
Yes, that sounds correct, using the Advanced Drawing API:
modelName = IO.Path.GetFileName(ThisDrawing.ModelDocument.FullFileName) MsgBox(modelName)
You don't usually even need the Dim keyword to declare a local variable. Sometimes you run into issues though when you explicitly have to declare the variable with the correct type, e.g.:
Dim doc As PartDocument
These variables are only available while the Rule is running. If that's enough for you then no need to store it as an iProperty.
Cheers,
Does this "stabilize model name" method work with the new iLogic functionality introduced in Inv 2019?
Especially, the commands, Components.Add and Components.AddiPart?
Can iLogic change the browser name after it is added with the commands above?
Regards,
Jerry
Can iLogic change the browser name after it is added with the commands above?
compoccurrence.name ="" ' this will reset name to correct one if you need different just type it in to quotation marks
Thanks for the code reference. Perhaps someone will post soon some iLogic samples with "stabilized browser names" and code that uses the component add and delete functions.
The goal is to have a master assembly in Vault (Basic) that gets design copied, necessary files renamed, check-out assembly, run the iLogic code to customize the design, and then check it all into Vault. Repeat for the next job.
Thanks again for sharing the info.
Regards,
Jerry
No. From what I have read, it is best that the browser name and filename do not match exactly.
This is the challenge that I am trying to understand/solve:
What I am not sure is the best order for this workflow.
Then once the design is in the Vault, with the renamed files, will the form/rules work in the copied files after you have used Copy Design?
It would be great if you could use Vault's Copy Design and the rules would update to match the filenames, but that does not work - yet. So a generic filename is required in the browser. Just trying to get all these tools to work together.
Regards,
Jerry
Hi,
You always could use :
Dim ass As AssemblyDocument
ass = ThisApplication.ActiveDocument
Dim occ As ComponentOccurrence
Dim doc As Document
For Each occ In ass.ComponentDefinition.Occurrences
or
For Each doc In ass.AllReferencedDocuments
and use some rules for example
if doc.subtype = sheetmetal then
export dxf.
or give your files types or special marking using iproperties... you have plenty of options
@JBerns, if you can can do all the required changes and run the rules for a particular configuration before you do the Copy Design, that makes it easier. Then you don't have to run the rules after the copy has been made and the filenames have been changed. But it sounds like that's not practical.
When you copy a design, do you follow a standard naming convention? Maybe you add the same prefix and suffix to all file names? If so, you can write the rules so that they add that prefix or suffix to all the hardcoded filenames. A parameter or iProperty in the assembly could hold the prefix or suffix.