Showing posts with label ilogic. Show all posts
Showing posts with label ilogic. Show all posts
Monday, January 1, 2018
iLogic to Rename All Solid Bodies
iLogic to Rename All Solid Bodies
Issue:
Youve created a multi-body solid model with the intent to use the Make Components tool to write out each solid as a new part file. This works fine, but you find yourself wishing there was an easier way to tag each solid with a new name based on a prefix and a series number. For instance, youd like to name each solid in a part file called 45-723 as such: 45-723_01, 45-723_02, 45-723_03, etc.

Issue:
You can use this iLogic rule to quickly rename the solid bodies for you. In this rule we first look for a custom iProperty named "Prefix" and create it if it is not present. Then we write the part number to the custom iProperty if it is found to be empty. Then the rule uses the value of the custom iProperty named "Prefix" in an input box to query the user for the prefix:
Thanks to Barbara Han for the original code I used for this rule.
------- start of ilogic ------
check for custom iProperty and add it if not found
Dim prefix As String = "Prefix"
customPropertySet = ThisDoc.Document.PropertySets.Item _
("Inventor User Defined Properties")
Try
prop= customPropertySet.Item(prefix)
Catch
Assume error means not found
customPropertySet.Add("", prefix)
End Try
write the part number to the Prefix iProperty if it is empty
if iProperties.Value("Custom", "Prefix") = "" Then
iProperties.Value("Custom", "Prefix") = iProperties.Value("Project", "Part Number") & "_"
else
end if
check that this active document is a part file
Dim partDoc As PartDocument
link download
Read more »
Sunday, December 31, 2017
iLogic Batch Output PDFs from an Assembly File
iLogic Batch Output PDFs from an Assembly File
Issue:
Youd like to output a PDF file from the drawings of all the components found in an assembly file (if those components have a drawing file created), and you like also create a PDF of the top level assembly drawing as well. All of these PDFs should be written out to a single folder. Can this be done?

Heres an ilogic rule to batch output PDF files for each component in an assembly. This rule assumes that the component drawings share the same name and location of the component.
For example: C:Tempwidget-450.ipt has a drawing: C:Tempwidget-450.idw
If the drawing file is not found, then it simply moves on and looks at the next component.
This rule may not work for everyone, but it should provide a starting point from which it can be modified as needed. If you work with *.dwg files rather than *.idw files you can search and replace this code for idw and replace with dwg.
Here is the code in a *.txt file that can be downloaded as well:
http://forums.autodesk.com/autodesk/attachments/autodesk/78/455124/2/Batch%20PDFs.txt
define the active document as an assembly file
Dim oAsmDoc As AssemblyDocument
oAsmDoc = ThisApplication.ActiveDocument
oAsmName = Left(oAsmDoc.DisplayName, Len(oAsmDoc.DisplayName) -4)
check that the active document is an assembly file
If ThisApplication.ActiveDocument.DocumentType <> kAssemblyDocumentObject Then
MessageBox.Show("Please run this rule from the assembly file.", "iLogic")
Exit Sub
End If
get user input
RUsure = MessageBox.Show ( _
"This will create a PDF file for all of the asembly components that have drawings files." _
& vblf & "This rule expects that the drawing file shares the same name and location as the component." _
& vblf & " " _
& vblf & "Are you sure you want to create PDF Drawings for all of the assembly components?" _
& vblf & "This could take a while.", "iLogic - Batch Output PDFs ",MessageBoxButtons.YesNo)
If RUsure = vbNo Then
Return
Else
End If
- - - - - - - - - - - - -PDF setup - - - - - - - - - - - -
oPath = ThisDoc.Path
PDFAddIn = ThisApplication.ApplicationAddIns.ItemById("{0AC6FD96-2F4D-42CE-8BE0-8AEA580399E4}")
oContext = ThisApplication.TransientObjects.CreateTranslationContext
oContext.Type = IOMechanismEnum.kFileBrowseIOMechanism
oOptions = ThisApplication.TransientObjects.CreateNameValueMap
oDataMedium = ThisApplication.TransientObjects.CreateDataMedium
If PDFAddIn.HasSaveCopyAsOptions(oDataMedium, link download
Read more »
iLogic and the Inventor Project File
iLogic and the Inventor Project File

Issue:
You want to reference the current Inventor Project file within an iLogic rule.
Solution:
Here is a quick iLogic snippet that will demonstrate how to work with the Project file and path. In this example the project name, project file name, project path, and the full project path and file name are written to a message box.

------ start of iLogic ----------------------------------------------------------
Dim IPJ as String
Dim IPJ_Name as String
Dim IPJ_Path as String
Dim FNamePos As Long
set a reference to the FileLocations object.
IPJ = ThisApplication.FileLocations.FileLocationsFile
get the location of the last backslash seperator
FNamePos = InStrRev(IPJ, "", -1)
get the project file name with the file extension
IPJ_Name = Right(IPJ, Len(IPJ) - FNamePos)
get the project name (without extension)
IPJ_ShortName = Left(IPJ_Name, Len(IPJ_Name) - 4)
get the path of the folder containing the project file
Read more »
iLogic How to learn Inventors Application Programming Interface API
iLogic How to learn Inventors Application Programming Interface API
Issue:
Youve been somewhat successful using iLogic code examples that you find online, but youd really like to learn how to create your own code from scratch. So how do these other people find the programming calls to create new code? It seems that there is some missing puzzle piece that you cant seem to locate, something that explains how to get started programming in Inventor. Does something like that exist?

Solution:
Programming in iLogic involves two different methods, that are often mixed together. The first method is to use "native" iLogic functions, the second is to use "raw" API functions by employing Inventors Application Programming Interface (API).
- "Native" iLogic functions are a dictionary of automation functions that deliver the power of Inventors Application Programming Interface (API) to users by using single-line automation functions. So you can think of iLogic as a collection of the more common programming and automation tasks that the developers have "cleaned" up so that users can create some Rule based automation in their design. This mean that the iLogic dictionary is just a simple subset of the larger API collection.
- "Raw" API language can be run using the iLogic tools as well, but will require more knowledge of VB.Net based syntax, and more need to declare and define within the code language. To get started with Inventors Application Programming Interface (API) you can use the following links.
********** ********** ********** ********** ********** ********** ********** ********** **********
This paper provides a brief overview of Inventor�s programming interface and illustrates this with examples using iProperties:
**missing link**
********** ********** ********** ********** ********** ********** ********** ********** **********
********** ********** ********** ********** ********** ********** ********** ********** **********
The following resource will help you get started with programming Inventor. It assumes familiarity with Autodesk Inventor and general programming concepts:
DevTV: Introduction to Inventor Programming, a self-paced video tutorial demonstrating how to get started developing with Autodesk Inventor.
View online | Download (zip file- 51.8 MB)
********** ********** ********** ********** ********** ********** ********** ********** **********
********** ********** ********** ********** ********** ********** ********** ********** **********
The links above as well as additional information concerning the Autodesk Developer Network resources, can be found at this link:
http://usa.autodesk.com/adsk/servlet/index?id=1079044&siteID=123112
********** ********** ********** ********** ********** ********** ********** ********** **********
********** ********** ********** ********** ********** ********** ********** ********** **********
Labels:
api,
application,
how,
ilogic,
interface,
inventors,
learn,
programming,
to
Subscribe to:
Comments (Atom)