- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
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!
Solved! Go to Solution.