Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Issues with Sketched Symbols with Prompted Entry using iLogic

7 REPLIES 7
SOLVED
Reply
Message 1 of 8
sergio_duran
1109 Views, 7 Replies

Issues with Sketched Symbols with Prompted Entry using iLogic

Hi Everyone,

 

I'm trying to insert a Sketched Symbol with prompted entry using iLogic but always get an error. I can actually insert Sketched Symbols without prompted entries and with prompted entries using API with the VBA editor. However, I need to do it in the iLogic editor. I can only insert Sketched Symbols without prompted entries with iLogic, but when I try the one with prompted entries, it fails.

 

I know that the PrompString is an array of Strings and I have used to options:

 

'This one works in the VBA Editor (API)

Dim oBalloonNo(0) As String
oBalloonNo(0) = "01"

 

OR

 

oBalloonNo = New String(0){"01"}

 

However none of them works in the iLogic editor. Do you know why? I know that the error is happening because of the PrompString option

 

Here is my code in iLogic (Error at the end)

SyntaxEditor Code Snippet

'Get the active document - drawing
oDoc = ThisApplication.ActiveDocument

'Get the Sheets collection
oSheets=oDoc.Sheets
'Get the first  sheet
oSheet=oSheets.Item(1)
'Get the drawing views collection
oDrawingViews=oSheet.DrawingViews
'Get the first drawing view of sheet #1 (Main View)
Dim oView As DrawingView
oView=oDrawingViews.Item(1)

'Get the referenced document - Assembly file
'oAssyDoc = oView.ReferencedDocumentDescriptor.ReferencedDocument oAssyDoc = ThisDrawing.ModelDocument 'Get the set of Work Points Dim oAssyWorkPoints As WorkPoints oAssyWorkPoints=oAssyDoc.ComponentDefinition.WorkPoints 'Get Work Point #71 oWPo71 = oAssyWorkPoints.Item(71) 'Create centermarks/centerlines based on the Work Features oCMark71 = oSheet.Centermarks.AddByWorkFeature(oWPo71, oView) oCMark71.Visible=False oIntent71 = oSheet.CreateGeometryIntent(oCMark71) 'Get the Sketched Symbol "Balloons" oSketchSymbolDef = oDoc.SketchedSymbolDefinitions.Item("Balloons") 'Create a point for the text/symbol oTG = ThisApplication.TransientGeometry Dim oPoint2D As Point2D oPoint2D = oTG.CreatePoint2d(oIntent71.PointOnSheet.X,oIntent71.PointOnSheet.Y) 'Dim oBalloonNo(0) As String
'oBalloonNo(0) = "01" oBalloonNo = New String(0){"01"} 'SketchedSymbols.Add( SketchedSymbolDefinition As Variant, Position As Point2d, [Rotation] As Double, [Scale] As Double, [PromptStrings] As Variant ) As SketchedSymbol oSheet.SketchedSymbols.Add(oSketchSymbolDef, oPoint2D, 0, 1, oBalloonNo)

 

Here is my VBA Code (API), it works!:

Public Sub InsertSketchedSymbol()

'Get the active document - drawing
Dim oDoc As Document
Set oDoc = ThisApplication.ActiveDocument

'Get the Sheets collection
Dim oSheets As Sheets
Set oSheets = oDoc.Sheets
'Get the first sheet
Dim oSheet As Sheet
Set oSheet = oSheets.Item(1)
'Get the drawing views collection
Dim oDrawingViews As DrawingViews
Set oDrawingViews = oSheet.DrawingViews
'Get the first drawing view of sheet #1 (Main View)
Dim oView As DrawingView
Set oView = oDrawingViews.Item(1)

'Get the referenced document - Assembly file
Dim oAssyDoc As Document
Set oAssyDoc = oView.ReferencedDocumentDescriptor.ReferencedDocument

'Get the set of Work Points
Dim oAssyWorkPoints As WorkPoints
Set oAssyWorkPoints = oAssyDoc.ComponentDefinition.WorkPoints

'Get Work Point #71
Dim oWPo71 As WorkPoint
Set oWPo71 = oAssyWorkPoints.Item(71)

'Create centermarks/centerlines based on the Work Features
Dim oCMark71 As Centermark
Set oCMark71 = oSheet.Centermarks.AddByWorkFeature(oWPo71, oView)

oCMark71.Visible = False

Dim oIntent71 As GeometryIntent
Set oIntent71 = oSheet.CreateGeometryIntent(oCMark71)

'Get the Sketched Symbol "Balloons"
Dim oSketchSymbolDef As SketchedSymbolDefinition
Set oSketchSymbolDef = oDoc.SketchedSymbolDefinitions.Item("Balloons")

'Create a point for the text/symbol
Dim oTG As TransientGeometry
Set oTG = ThisApplication.TransientGeometry

Dim oPoint2D As Point2d
Set oPoint2D = oTG.CreatePoint2d(oIntent71.PointOnSheet.X, oIntent71.PointOnSheet.Y)

Dim oBalloonNo(0) As String
oBalloonNo(0) = "01"

'SketchedSymbols.Add( SketchedSymbolDefinition As Variant, Position As Point2d, [Rotation] As Double, [Scale] As Double, [PromptStrings] As Variant ) As SketchedSymbol
Dim oSketchedSymbol As SketchedSymbol
Set oSketchedSymbol = oSheet.SketchedSymbols.Add(oSketchSymbolDef, oPoint2D, 0, 1, oBalloonNo)
End Sub

 

Thanks!

 

7 REPLIES 7
Message 2 of 8

How many prompted entry fields are in your sketched symbol?

 

Your code needs 1 string per prompted entry.


--------------------------------------
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 8

Hi Justin,

 

There is only one in the Sketched Symbol.

 

My VBA (API) code successfully inserts the Sketched Symbol with the string "01". My iLogic fails.

 

Thanks!

Message 4 of 8

Hmmm. Doesn't sound right, and the code looks right to me.

 

Maybe it's a bugged instance of inventor? Maybe it doesn't like the point on the centermark? 

 

What version of inventor are you using?


--------------------------------------
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 5 of 8

Hi Justin,

 

The codes have been tested in Inventor Pro 2016 and 2018.

 

Thanks!

Message 6 of 8
sergio_duran
in reply to: sergio_duran

Justin,

 

I also changed the WorkPoint and created a WorkAxis. Then, I tried with a Centerline instead of centermark.

 

I got the same result in Ilogic. If I try with a Sketched Symbol without prompted entry, it works. However, a Sketched Symbol with prompted entry doesn't work in iLogic.

 

When using Centerline, I used either the StartPoint or EndPoint, but it doesn't work either

Message 7 of 8
sergio_duran
in reply to: sergio_duran

I solved the iLogic code. Basically I needed to declare (Dim As) all objects because I didn't know which one was failing and it worked. I had this issue before with another iLogic rule. In theory, when you use API objects in an iLogic rule, there is no need to declare them, but there are some objects (I don't know which ones) that will fail if the object is not declared before using methods and properties.

Message 8 of 8

I've ran into it a lot too, and it seems very hit or miss.

 

Sometimes it seems a different instance of inventor won't have the same problem.

 

Fool proof way to prevent is to definitely declare everything though.


--------------------------------------
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

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Technology Administrators


Autodesk Design & Make Report