iLogic Place sketch symbol with prompted entry

iLogic Place sketch symbol with prompted entry

Stryder33345
Enthusiast Enthusiast
2,217 Views
3 Replies
Message 1 of 4

iLogic Place sketch symbol with prompted entry

Stryder33345
Enthusiast
Enthusiast

Hi all,

    I would like to place a sketch symbol that has prompted entry on a drawing sheet with iLogic code. I have the code to place one that does not have prompted entry, I was hoping someone could help me with some example code to place one with prompted entry.

 

 

Thanks in advance

Stryder

 

 

Inventor 2016

windows 7

0 Likes
Accepted solutions (1)
2,218 Views
3 Replies
Replies (3)
Message 2 of 4

MechMachineMan
Advisor
Advisor
Accepted solution

1. Utilize programming help. As found on you computer or through inventor. You can search through the reference there and find the proper syntax. It also helps finding a version of the API Object Model for the version of inventor you are using to quickly find the objects in question, helping search for them.

 

2. It will utilize something like:

 

Dim oSketchedSymbolDef As SketchedSymbolDefinition

Dim oInsertionPoint As Point2d

 

oSketchedSymbolDef = ThisApplication.ActiveDocument.SketchedSymbolDefinitions.Item("SketchedName")

oInsertionPoint = ThisApplication.ActiveDocument.TransientGeometry.CreatePoint2d(x_value, y_value)

 

Dim oPromptStrings As String() = {"PromptField1","PromptField2"}

 

oSheet.SketchedSymbols.Add(oSketchedSymbolDef, oInsertionPoints, 0, 1, oPromptStrings) 

 

3. Be careful that you prompt string always matches the number of fields of prompted entry; use "" for blank fields.


--------------------------------------
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
Message 3 of 4

Stryder33345
Enthusiast
Enthusiast

Thankyou for the help mech. I use the API and object tree often, just thought it might be quicker when I posted this if someone had some example code as I was in a pinch and have not had the time to solve the problem. I actually had it very close, I was just missing the curly braces around the prompts. Much appreciated for the code though, always good that people share there skills here.

0 Likes
Message 4 of 4

Anonymous
Not applicable

You can create a sketch symbol which has prompted entry while formatting the sketch of the symbol. No iLogic required.

 

I also have symbols that i place under views though using ilogic & forms. This is the code,

 

You could probably find something usefull in this:

 

Dim oApp As Application: oApp = ThisApplication
Dim oDoc As DrawingDocument: oDoc = oApp.ActiveDocument
Dim oSheet As Sheet: oSheet = oDoc.ActiveSheet

'This uses a sketch symbol with the name "'View On' View Label"
Dim oSymDef As SketchedSymbolDefinition: oSymDef = oDoc.SketchedSymbolDefinitions.Item("'Item' View Label")

'This is the selected view
Dim oView As DrawingView: oView = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kDrawingViewFilter,"Select View To Place Symbol:")

'This takes the label items of the selected view
'And adds it To an array that will link To the prompted entry
Dim sPromptStrings(4) As String
sPromptStrings(0) = oView.Name
sPromptStrings(1) = oView.ScaleString
sPromptStrings(2) = ""
sPromptStrings(3) = ""
sPromptStrings(4) = ""


'This is the position for the sketched symbol under the selected view'
Dim oPosition As Point2d: oPosition = oView.Center
oPosition.y = oPosition.y - (oView.Height / 2 + 2.5)

'This inserts the sketched symbol and fills in the prompted entry.
Dim oSymbol As SketchedSymbol: oSymbol = oSheet.SketchedSymbols.Add(oSymDef, oPosition, , ,sPromptStrings)