Hey All Please Help......
I want Inventor to add sketch symbols automaticly on cordinates according to a Custom Text Paramater
for example I have created Custom Multi Value Text User parameter Approved & Not Approved or Plate Work Notes & SteelWork Notes wich each represent diffrent sketch symbols that needs to be placed out base on the value selected. Each sheet consist of diffrent sketch symbols
Any Help will be much Appreciated or example Ilogic Rule
Thanks
Carl
Solved! Go to Solution.
Solved by Vladimir.Ananyev. Go to Solution.
Your problem can be solved.
Inventor DrawingDocument API allows you (a) create new sketched symbol definition object on-the-fly and (b) insert existing sketched symbol definition into the drawing sheet.
The following rule inserts the sketched symbol definition "SymbolA" into the active sheet, insertion point (10 cm, 10 cm).
'Sub Main() ' Set a reference to the drawing document. ' This assumes a drawing document is active. Dim oDrawDoc As DrawingDocument = ThisDrawing.Document ' Obtain a reference to the desired sketched symbol definition. Dim oSketchedSymbolDef As SketchedSymbolDefinition _ = oDrawDoc.SketchedSymbolDefinitions.Item("SymbolA") Dim oSheet As Sheet = oDrawDoc.ActiveSheet 'create insertion point, coordinates - in cm ! Dim oTG As TransientGeometry = ThisApplication.TransientGeometry Dim oInsertionPoint As Point2d = oTG.CreatePoint2d(10, 10) ' Add an instance of the sketched symbol definition to the sheet. ' Rotate angle = 0 radians, ' scale = 1 when adding ' no prompt text Dim oSketchedSymbol As SketchedSymbol _ = oSheet.SketchedSymbols.Add( _ oSketchedSymbolDef, _ oInsertionPoint, _ 0, 1, Nothing) 'End Sub
Look Inventor API Help for the sample code “Create SketchedSymbol Definition API Sample“ for more details.
Cheers,
I paste this Exact code into a iLogic rule, with a SymboA defined in my Sketched symbols, and I ge tthis error
Error in rule: Rule0, in document: Drawing1
The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG))
I'm using Inventor 2014, I have also tried it in Inventor 2015
thoughts?
When i tried for first time i got same error. I changed Symbol1A into one of my sketched symbols and is working. Inventor 2012. Would be nice run this rule and with pick geometry to start symbol with leader.
Would be this possible, Vladimir?
Thank you
Did you copy and paste code in text editor first?Word maybe? I do all the time
'Sub Main() ' Set a reference to the drawing document. ' This assumes a drawing document is active. Dim oDrawDoc As DrawingDocument = ThisDrawing.Document ' Obtain a reference to the desired sketched symbol definition. Dim oSketchedSymbolDef As SketchedSymbolDefinition _ = oDrawDoc.SketchedSymbolDefinitions.Item("SymbolA") Dim oSheet As Sheet = oDrawDoc.ActiveSheet 'create insertion point, coordinates - in cm ! Dim oTG As TransientGeometry = ThisApplication.TransientGeometry Dim oInsertionPoint As Point2d = oTG.CreatePoint2d(10, 10) ' Add an instance of the sketched symbol definition to the sheet. ' Rotate angle = 0 radians, ' scale = 1 when adding ' no prompt text Dim oSketchedSymbol As SketchedSymbol _ = oSheet.SketchedSymbols.Add( _ oSketchedSymbolDef, _ oInsertionPoint, _ 0, 1, Nothing) 'End Sub
This is a COPY paste from my ilogic rule
I copied to Word, and tried Notepad still exact error
System.ArgumentException: The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG))
at System.RuntimeType.ForwardCallToInvokeMember(String memberName, BindingFlags flags, Object target, Int32[] aWrapperTypes, MessageData& msgData)
at Inventor.SketchedSymbols.Add(Object SketchedSymbolDefinition, Point2d Position, Double Rotation, Double Scale, Object PromptStrings)
at LmiRuleScript.Main()
at Autodesk.iLogic.Exec.AppDomExec.ExecRuleInAssembly(Assembly assem)
at iLogic.RuleEvalContainer.ExecRuleEval(String execRule)
Hi kimhendrix,
In your original message you say "paste this Exact code into a iLogic rule, with a SymboA.."
That might just be a typo, but I wanted to point out that the rule is looking for a symbol named SymbolA rather than SymboA.
I did test the rule, where I didn't have a symbol named SymbolA, and it appeared to throw the same error you're seeing.
Aside from that the other thing that you might try is to change the first line from:
Dim oDrawDoc As DrawingDocument = ThisDrawing.Document
to:
Dim oDrawDoc As DrawingDocument = ThisDoc.Document
Otherwise, the rule works fine for me.
I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com
If you have prompted entry in symbol rule won't work.
Curtis, how about to pick line in drawing after run rule and pull leader wit symbol, is that possible?
Thank you
I have the need to insert a block or symbol in the drawing sheet, but the position in which it is inserted changes with respect to the format that is used at the moment, the insertion position can be adjusted programmatically if it is A4 or A3 etc.
It is really the symbol itself. If an input is required by the symbol, then the rule does not work. If it is an icon without a request for input, then the rule works.
Does anyone perhaps already have a solution for an icon with a request for input?
Greetings
Leo
For sketch symbols with prompted entries, the argument "PromptStrings" of "SketchedSymbols.Add" requires a array of strings, even if it is a single entry:
Dim promptText(0) As String
promptText(0) = "99"
I found that the above did not work with a simple string, but worked once it was an array with a single string. Found this the hard way, then I read the documentation closer and sure enough it states "Optional input array of Strings"
Thanks for your answer.
It doesn't quite work for me yet. How do I include the code from you?
My code looks like this:
Parameter.UpdateAfterChange = True
'Sub Main()
' Set a reference to the drawing document.
' This assumes a drawing document is active.
Dim oDrawDoc As DrawingDocument = ThisDoc.Document
' Obtain a reference to the desired sketched symbol definition.
Dim oSketchedSymbolDef As SketchedSymbolDefinition _
= oDrawDoc.SketchedSymbolDefinitions.Item("Oberflächen, Sammelangabe w, x, y (3 Qualitäten, nicht vordefiniert)")
Dim oSheet As Sheet = oDrawDoc.ActiveSheet
'create insertion point, coordinates - in cm !
Dim oTG As TransientGeometry = ThisApplication.TransientGeometry
Dim oInsertionPoint As Point2d = oTG.CreatePoint2d(10, 10)
Dim promptText(0) As String
promptText(0) = "99"
Dim oSketchedSymbol As SketchedSymbol _
= oSheet.SketchedSymbols.Add( _
oSketchedSymbolDef, _
oInsertionPoint, _
0, 1, Nothing)
'End Sub
I get the following error:
Error in line 24 in rule Surfaces, collective specification w, x, y (3 qualities, not predefined), in document Drawing (DWV).idw
Wrong parameter. (Exception of HRESULT: 0x80070057 (E_INVALIDARG))
My goal is to easily call the following dialog from Inventor from my sketch icon via a rule:
@leoow96
Have a look at the documentation for the .Add method of the SketchedSymbols object:
https://help.autodesk.com/view/INVNTOR/2022/ENU/?guid=SketchedSymbols_Add
The 5th argument of SketchedSymbols.Add() is "PromptStrings" as Variant.
Your code has the 5th argument as "Nothing". You need to change that to be the array of strings "PromptText".
Now it works so far, with an empty string! Now my symbol is placed.
How do I get it now that the window opens to edit the properties?
I would be reluctant to make a query that asks for the value.
Having the GUI window open up kind of defeats the purpose of using the code to generate the SketchedSymbol. You probably want the code to create these entries, right?
I'm not sure why the string in your Sketched Symbol is empty, but I see from the image you posted that your SketchedSymbol contains two entries. You probably need a string array of length 2, with each filled out:
Dim promptText(1) As String 'String Array of length 2
promptText(0) = "First Entry"
promptText(1) = "Second Entry"
Can't find what you're looking for? Ask the community or share your knowledge.