need a iLogic snippet to look for a part?

need a iLogic snippet to look for a part?

chris
Advisor Advisor
1,395 Views
7 Replies
Message 1 of 8

need a iLogic snippet to look for a part?

chris
Advisor
Advisor

Okay, I'm sure iLogic can do this, but what snippet is used when I need to make a parameter in my open doc. equal the parameter in another doc... that is not included in the active assembly?

Can iLogic look at a part that is not included in the active assembly?

 

I found the "path", "Filename", "Pathandfilename"...

 

just not sure how to make them work.

I just need to make it look into another folder... also, does the part I'm looking at have to be in the "active" projectiLogic.PNG

0 Likes
1,396 Views
7 Replies
Replies (7)
Message 2 of 8

mcgyvr
Consultant
Consultant

Any specific reason you want to use ilogic vs just out of the box parameter linking functionality?

https://knowledge.autodesk.com/support/inventor-products/troubleshooting/caas/sfdcarticles/sfdcartic...

 



-------------------------------------------------------------------------------------------
Inventor 2023 - Dell Precision 5570

Did you find this reply helpful ? If so please use the Accept Solution button below.
Maybe buy me a beer through Venmo @mcgyvr1269
0 Likes
Message 3 of 8

chris
Advisor
Advisor

I was using the parameter linking... but it started getting "heavy" and I have not found a way to "auto include" any new parameters created in the linked part, so I keep having to "update" the part I'm in to see any new parameters created in the other part... just seems easier with iLogic.

 

My current project  is an automated assembly, so all parts in the assembly reference back to a base part, but if I create a new parameter at the base part, I then have to go into every other part and "update" the linked component to see the new parameter... with iLogic I can just make parameter = parameter... (I already know the parameter's name), it's just easier to deal with... obviously this is not an issue if the base part is included in the assembly, but I was wondering if it could be done without including it in the assembly... does iLogic have the ability to look at a part in or outside of a current project location?

 

I know it can look-up an excel file, but that file has to be in the current project or the same folder (I thought) as the part that is looking it up

0 Likes
Message 4 of 8

Curtis_Waguespack
Consultant
Consultant

Hi @chris,

 

First, remember that there is an Inventor Customization forum that is probably a better place to post ilogic and programming questions :
http://forums.autodesk.com/t5/Autodesk-Inventor-Customization/bd-p/120

 

Second, understand that there are straight ilogic functions and then there are API (application programming interface) calls that we often use with ilogic to go beyond the simple set of iLogic functions. I mention this because most of the iLogic functions are intended to work with the current active document, and/or to reach through the current active document into it's referenced files.

 

So with all of that in mind for the future, to get back to your question, the answer is yes, if we know the path and filename of the file we want to access, then we can open it into the session of Inventor and write to it's iprops, and then save and close it.

 

Here is a quick example that combines ilogic functions and API calls to open a file invisibly from a hard coded file path and name, then shows the existing part number, gets a new part number, and saves and closed the file. More typically we'd determine path and file name more dynamically, but sometimes it might be static like this simple example.

 

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

 

 

sFolder = "C:\TEMP\"
sName = "A100-02.ipt"
sFile = sFolder & sName

'open the file, false opens the file without generating the graphics
oDoc = ThisApplication.Documents.Open(sFile, False) 

'get part number iProp
oPN = iProperties.Value(oDoc, "Project", "Part Number")

'show existing part number
MessageBox.Show(oPN, "iLogic")

'get user input
oPN = InputBox("Enter new Part Number", "iogic", oPN)

'write user input to part number iProp
iProperties.Value(oDoc, "Project", "Part Number") = oPN

'close doc, True saves the doc on close
oDoc.Close(True)

EESignature

0 Likes
Message 5 of 8

MechMachineMan
Advisor
Advisor

The existing documentation is great for this.... :

 

https://knowledge.autodesk.com/support/inventor-products/learn-explore/caas/CloudHelp/cloudhelp/2015...

 

 

 

And to answer your other question: NO, iLogic cannot access files that are not a direct child of the open document.

Sadly, I've tested a couple cases and found:

- You cannot even use the file name to access the top level file to assign an iProperty as it causes an error. (iProperties.Value(System.IO.Path.GetFileName(ThisDoc.Document), "Project", "Part Number") is an example that fails)

- You cannot use the file name to access the drawing of the current part, even if it is open. (Using a similiar call to above, but changing the file name)

 

 

If you were to want to do this, you would have to use the API directly such as:

 

 

oSourceDoc = ThisApplication.Documents.Open("C:\SourceFile.ipt",False)
oSourceParams = oSourceDoc.ComponentDefinition.Parameters
Try
    oLen = oSourceParams("Length").Value
    Parameter("Length") = oLen
Catch
    MsgBox("Error Assigning Parameter.")
End Try
oSourceDoc.Close

 


--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.

Justin K
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization


iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread

Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects

Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help

Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type
0 Likes
Message 6 of 8

Curtis_Waguespack
Consultant
Consultant

@chris wrote:

 

My current project  is an automated assembly, so all parts in the assembly reference back to a base part, but if I create a new parameter at the base part, I then have to go into every other part and "update" the linked component to see the new parameter...


Also, see this link, it pushes all of the custom parameters in the assembly to all of the referenced parts:

https://forums.autodesk.com/t5/inventor-forum/create-parameters-in-assembly-with-ilogic-rule/m-p/687...

 

From your earlier description I'm unsure if your "base part" is referenced or not, but if so, something like the example at that link is probably the way to go.

 

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com
 

EESignature

0 Likes
Message 7 of 8

chris
Advisor
Advisor

Yes, all the other parts in the assembly reference the parameters of the "base part"... it's more or less a skeleton model, but without the skeleton and only looking at parameters

0 Likes
Message 8 of 8

ithelpdesk
Explorer
Explorer

Hi, 

   i am trying to automate the process.can any one help me.

1)I have an Assembly file with all parts.

2) Select the part which as description starting "PL".

.3) open the part and select the face export to ".dxf and close

4) if the part is sheet metal then unfold and export face as ".dxf

Note: the face which is to be exported may be part file or sheet metal file.

kindly help me to solve this.

 

thanks

Sri 

 

0 Likes