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: 

Creating Intelligent sketched symbols

19 REPLIES 19
Reply
Message 1 of 20
dunc1n
4689 Views, 19 Replies

Creating Intelligent sketched symbols

Hi Folks, I got another question for you all.

 

I am currently working on creating new symbols. Now I want to keep the look of the symbol (see attached) but I want all the text to be automated as the text is currently "prompted entry".

Now when I go into the edit the text within the symbol sketch, I need the "view label properties" from the drop down menu but its not there!?!?! Is there a way that I can get the "view label properties" into the drop down menu??? What I am after is to attach this symbol to a view and the symbol will automatically show the name of the view and the scale.

 

OR........ If there is any way that I can get default view label to look like my symbol???? This would probably be the better idea but Im pretty sure you cannot edit the look of the view label symbol.......... but hopefully Im wrong with this???

 

Thanks again folks

 

Dunc1n

19 REPLIES 19
Message 2 of 20
ChristinaForest
in reply to: dunc1n

Do you know to make your symbol now? I want to make the similar symbole with scale view in?

Message 3 of 20

Hi sergelachance,

 

Here is what I've come up with based on jdkriek's great example at this thread:

http://forums.autodesk.com/t5/Autodesk-Inventor-Customization/iLogic-Controlled-Sketch-Symbol/td-p/3...

 

The rule first looks for existing view label symbols and removes them, then replaces them on all of the sheets. This rule could use some refinement, so if you improve upon it please post back some examples.

 

Also, I've attached an example drawing file that you can use to see how this is set up.

 

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com


 

 

Dim oDoc As DrawingDocument
oDoc = ThisDoc.Document
Dim oSheets As Sheets
oSheets = oDoc.Sheets
Dim oSheet As Sheet
Dim oViews As DrawingViews
Dim oView As DrawingView
Dim oSymbol As SketchedSymbol
Dim oSymbols As SketchedSymbols

'iterate through all of the sheets
For Each oSheet In oSheets
    'remove existing sketched symbols named View Label
    For Each oSymbol  In oSheet.SketchedSymbols
    If oSymbol.Definition.Name = "View_Label" Then
    oSymbol.Delete
    Else
    End if
    Next
    
'set sheet active    
oSheet.Activate
'set a refernce to the drawing views collection
oViews = oDoc.ActiveSheet.DrawingViews
    ' Iterate through all of the views
    For Each oView In oViews
    'This places a sketched symbol with the name "View_Label"
    Dim oSymDef As SketchedSymbolDefinition
    'defind the sketch symbol to be inserted
    oSymDef = oDoc.SketchedSymbolDefinitions.Item("View_Label")
    
    'set a string array with values for the prompted entries found in the symbol
    Dim sPromptStrings(1) As String
    sPromptStrings(0) = "SCALE " & oView.Scale 'set to view scale
    sPromptStrings(1) = oView.Name 'set to view name
    
    'set the position for the sketched symbol to be inserted
    ' and spaced off of the selected view center
    Dim oPosition As Point2d: oPosition = oView.Center
    oPosition.y = oPosition.y - (oView.Height / 2 + 0.6)
    'insert the sketched symbol and set the prompted entries
    oSymbol = oSheet.SketchedSymbols.Add(oSymDef, oPosition,0,1,sPromptStrings)
    Next    
Next

'activate sheet1
oDoc.Sheets.Item(1).Activate

 

Message 4 of 20

Thanks Curtis you are the king 🙂


@Curtis_Waguespack wrote:

Hi sergelachance,

 

Here is what I've come up with based on jdkriek's great example at this thread:

http://forums.autodesk.com/t5/Autodesk-Inventor-Customization/iLogic-Controlled-Sketch-Symbol/td-p/3...

 

The rule first looks for existing view label symbols and removes them, then replaces them on all of the sheets. This rule could use some refinement, so if you improve upon it please post back some examples.

 

Also, I've attached an example drawing file that you can use to see how this is set up.

 

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com


 

 

Dim oDoc As DrawingDocument
oDoc = ThisDoc.Document
Dim oSheets As Sheets
oSheets = oDoc.Sheets
Dim oSheet As Sheet
Dim oViews As DrawingViews
Dim oView As DrawingView
Dim oSymbol As SketchedSymbol
Dim oSymbols As SketchedSymbols

'iterate through all of the sheets
For Each oSheet In oSheets
    'remove existing sketched symbols named View Label
    For Each oSymbol  In oSheet.SketchedSymbols
    If oSymbol.Definition.Name = "View_Label" Then
    oSymbol.Delete
    Else
    End if
    Next
    
'set sheet active    
oSheet.Activate
'set a refernce to the drawing views collection
oViews = oDoc.ActiveSheet.DrawingViews
    ' Iterate through all of the views
    For Each oView In oViews
    'This places a sketched symbol with the name "View_Label"
    Dim oSymDef As SketchedSymbolDefinition
    'defind the sketch symbol to be inserted
    oSymDef = oDoc.SketchedSymbolDefinitions.Item("View_Label")
    
    'set a string array with values for the prompted entries found in the symbol
    Dim sPromptStrings(1) As String
    sPromptStrings(0) = "SCALE " & oView.Scale 'set to view scale
    sPromptStrings(1) = oView.Name 'set to view name
    
    'set the position for the sketched symbol to be inserted
    ' and spaced off of the selected view center
    Dim oPosition As Point2d: oPosition = oView.Center
    oPosition.y = oPosition.y - (oView.Height / 2 + 0.6)
    'insert the sketched symbol and set the prompted entries
    oSymbol = oSheet.SketchedSymbols.Add(oSymDef, oPosition,0,1,sPromptStrings)
    Next    
Next

'activate sheet1
oDoc.Sheets.Item(1).Activate

 


 

Message 5 of 20

AND IF I WANT MY SCALE IN INCHES 😉 DO YOU HAVE A SOLUTION AGAIN 🙂

Message 6 of 20

i dont want to insert and delete automaticaly the sketched symbol, because too many style in each sheet, i just want to update de oview name et oview scale of each symbols  in each sheets and it's possible to put the scale in feets? ex.:1/4"=1'-0"

 

Thanks for any help

Message 7 of 20

Hi,

 

I may not understand your question correctly. It looks you want to update the value of the prompt string (in inch) in a sketched symbol. If yes, I think you could just convert the scale to inch by UnitsOfMeasure.GetPreciseStringFromValue and set the argument. e.g. on the basis of the code above provied by Curtis.

 

'set to view scale

sPromptStrings(0) = "SCALE " & UnitsOfMeasure.GetPreciseStringFromValue(oView.Scale,kInchLengthUnits)

 

Message 8 of 20

Thanks for your reply xiaodong but dont work 😞

Message 9 of 20

Hi,

 

Could you elaborate what is your exact problem? any code and snapshot?

Message 10 of 20

IT'S NECESSARY TO DELETE AND REPLACE ALL SKETCHED SYMBOILS?

 

FIRST PIC = BEFORE CAPTURE SCREEN!

SECOND PIC = BEFORE RULE

THIRD PIC =  WITH YOUR RULE AND MY ERROR CODE

 

THANKS AGAIN FOR YOUR HELP 🙂

 

 

SCALE.PNGSCALE BEFORE.PNGSCALE AFTER WITH ERROR.PNG

Message 11 of 20

Hi,

 

Sorry, I was very busy on DevDays.

 

I struggled to reproduce your problem, however it is hard without reproducible sample. Could you provide a small source code? In addition, have you debugged to check the error message is due to the line of GetPreciseStringFromValue. Or could you create a smallest test function to run UnitsOfMeasure.GetPreciseStringFromValue(oView.Scale,kInchLengthUnits) only to see if it works?

 

Message 12 of 20

THE FILE!

 

SORRY REALLY REALLY BUSY TOO 🙂

 

IT'S REALLY NECESSARY TO DELETE AND INSERT THE TITLEBLOCK???

 

THANKS AGAIN FOR YOUR HELP 🙂

 

Message 13 of 20
shirazbj
in reply to: ChristinaForest

Hi,

 

You should change like below. It works for me under 2013 @ win 7 -32bit.

 

sPromptStrings(0) = "SCALE " & oDoc.UnitsOfMeasure.GetPreciseStringFromValue(oView.Scale,UnitsTypeEnum.kInchLengthUnits)

 But it adds an "In" at the end and looks strange.

 

Be aware, the scale value itself is UNIT-LESS. If you write like A:B, it is fine. You can convert A and B seperately.

If it is only a ratio value, there is no point to have a conversion.

 

Regards

 

Peter

Message 14 of 20
ChristinaForest
in reply to: shirazbj

the solution who work for me is

 

  sPromptStrings(0) = "SCALE " & oView.ScaleString 'set to view scale
Message 15 of 20
ahobby
in reply to: ChristinaForest

@ChristinaForest

 

I have been looking for something like this, putting this view label w/ 1/4" = 1'-0". Can you post the code you used to achieve this, thank you!

Message 16 of 20
ahobby
in reply to: ahobby

Hi @xiaodong_liang,

 

I stumbled upon this thread while trying to set up an inventor template to look something like our existing autocad template. I have been able to successfully get the code to work, but I would like to add in a couple user defined field. When I add those in the ilogic code breaks. Can you take a look at the attached and see if there is a solution here for me?

 

The picture below is the working view-label and the old one, who's layout I would like to use in the new view-label:

 

Error.jpg

 

many thanks,

Andrew

Message 17 of 20
MechMachineMan
in reply to: ahobby

Hi Andrew,

 

Without your code and a sample drawing with the sketched symbol in question, or more information it's hard to precisely diagnose the issue.

 

My guess is that you did not revise the code for adding the additional prompted entry string as is required for the change to the symbol definition.

 

For insterting/adding sketched symbols, the code my be supplied with promptstrings as corresponds to the number of prompted entry fields.

 

Searching sPromptStrings should find you more examples of such a scenario.


--------------------------------------
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 18 of 20
ahobby
in reply to: MechMachineMan

Hi Justin,

 

I've attached the drawing file and the code is pasted below. My understanding of ilogic is "extremely limited" - read: little to none.

FYI - This code was pasted earlier in the thread, I just copied it into my drawing along with the sketch symbol which I've modified to look more like our existing view label title block from Autocad.

 


Dim oDoc As DrawingDocument oDoc = ThisDoc.Document Dim oSheets As Sheets oSheets = oDoc.Sheets Dim oSheet As Sheet Dim oViews As DrawingViews Dim oView As DrawingView Dim oSymbol As SketchedSymbol Dim oSymbols As SketchedSymbols 'iterate through all of the sheets For Each oSheet In oSheets 'remove existing sketched symbols named View Label For Each oSymbol In oSheet.SketchedSymbols If oSymbol.Definition.Name = "View_Label" Then oSymbol.Delete Else End If Next 'set sheet active oSheet.Activate 'set a refernce to the drawing views collection oViews = oDoc.ActiveSheet.DrawingViews ' Iterate through all of the views For Each oView In oViews 'This places a sketched symbol with the name "View_Label" Dim oSymDef As SketchedSymbolDefinition 'defind the sketch symbol to be inserted oSymDef = oDoc.SketchedSymbolDefinitions.Item("View_Label") 'set a string array with values for the prompted entries found in the symbol Dim sPromptStrings(1) As String sPromptStrings(0) = "" & oView.ScaleString 'set to view scale sPromptStrings(1) = oView.Name 'set to view name 'set the position for the sketched symbol to be inserted ' and spaced off of the selected view center Dim oPosition As Point2d: oPosition = oView.Center oPosition.y = oPosition.y - (oView.Height / 2 + 2) 'insert the sketched symbol and set the prompted entries oSymbol = oSheet.SketchedSymbols.Add(oSymDef, oPosition,0,1,sPromptStrings) Next Next 'activate sheet1 oDoc.Sheets.Item(1).Activate

 

 

Message 19 of 20
ahobby
in reply to: ahobby

@MechMachineMan - I was able to add in the user prompted fields without the code creating an error, however when the rule runs now it deletes the existing text and replaces it with the default.

 

This is how I got it to recognize the other user prompted fields. Would the solution here be something to do with the beginning of the code where it clears all the existing blocks? That seems a pretty obvious place to start with...

 

SyntaxEditor Code Snippet

Dim sPromptStrings(4) As String 
     sPromptStrings(0) = "" & oView.ScaleString 'set to view scale
    sPromptStrings(1) = oView.Name 'set to view name
    sPromptStrings(2) = "DESCRIPTION"
    sPromptStrings(3) = "QTY"
    sPromptStrings(4) = "NOTE"

SyntaxEditor Code Snippet

'iterate through all of the sheets
For Each oSheet In oSheets
    'remove existing sketched symbols named View Label 
   For Each oSymbol  In oSheet.SketchedSymbols
   If oSymbol.Definition.Name = "View_Label" Then
   oSymbol.Delete
   Else 
    End If
    Next
    

 

 

Message 20 of 20
kadscad
in reply to: ahobby

Nice Job. I can't believe Autodesk doesn't have this along with other drafting symbols incorporated

Kirk
Inventor 2023

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

Post to forums  

Autodesk Design & Make Report