Apply scale to Sketch Symbol via iLogic

Apply scale to Sketch Symbol via iLogic

H4TSDESQ
Enthusiast Enthusiast
1,119 Views
4 Replies
Message 1 of 5

Apply scale to Sketch Symbol via iLogic

H4TSDESQ
Enthusiast
Enthusiast

Came across this post/tread  Insert Symbol onto Drawing View Using iLogic with some iLogic code that when run it would apply a predefined sketch symbol to the views currently on the sheet, as well as write the scale in a decimal value & title into the sketch symbol.

 

Is it possible to have iLogic write the scale in something like '1/8" = 1'-0" & title to the symbol without specifying a sketch symbol to use? I currently have two different symbols depending on if its a Section/Detail or a Plan view.

0 Likes
Accepted solutions (1)
1,120 Views
4 Replies
Replies (4)
Message 2 of 5

WCrihfield
Mentor
Mentor

So...

1) Are you wanting to change the view's label to show the scale text the way you want it?

2) Are you are wanting to edit/change existing text within a sketch symbol that already exists on the sheet?

3) Do you want to create a new sketch symbol from scratch to place on your sheet, that contains this custom view scale text?

4) Do the sketch symbol definitions that you want to use already exist in the sketch symbols library (or in the Document?), and you just want to place instanced of them on your sheet, then change the text within them?

If none of these is right, can you please explain the scenario in more detail, so we can better help you?

Screen captured images of what you have/want would be great too.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 3 of 5

Curtis_Waguespack
Consultant
Consultant
Accepted solution

Hi @H4TSDESQ 

 

Using the example at the link you pointed to, change this line:

sPromptStrings(0) = "SCALE " & oView.Scale 'set to view scale

to this, so that is uses .ScaleString rather than .Scale

sPromptStrings(0) = "SCALE " & oView.ScaleString 'set to view scale string, ex: 3/4" = 1'0"

This assumes the view is already using a scale string in that format.

 

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

EESignature

0 Likes
Message 4 of 5

H4TSDESQ
Enthusiast
Enthusiast

@WCrihfield, I have two variations of a view title. One of them is specific for Plans. The other applies to sections, details, & elevations. Currently in both there are prompted entries for the Title, Scale, Detail #, & a few lines of subtext if desired. In the Section view title, there's an additional 2 prompted entries for back referencing (so you know what sheet that reference came from). I'd like to have the iLogic script to only apply the Plan title to Base, Projected, & Auxiliary views. Then have the Section title be applied to Sections & Details.

 

1). Yes. And with the recommendation in post 2 I'm able to have it populate how I want.

2). This one's a toss-up. In most cases, the view title name that Inventor gives isn't what I'd want, so I think I'd still like to leave the Title as a prompted entry.

3/4). The two sketch symbols I want placed exist within the document, so new one's don't need to be made from scratch.

 

Sections/Details/ElevationsSections/Details/Elevations

PlansPlans

 

@Curtis_Waguespack, Thank you! Your comment does exactly what I was looking for.

0 Likes
Message 5 of 5

WCrihfield
Mentor
Mentor

Do you still need to know how to set up the iLogic rule so that it knows how to choose which specific sketch symbol to put by each view, based on the type of view it is?  There are several things you can check or filter by to make sure your targeting the right drawing views.  The view's ViewType (which uses the DrawingViewTypeEnum) is one popular thing you can check, and also the view camera's Camera.ViewOrientationType (which uses the ViewOrientationTypeEnum).  Here is something I put to together that may help with this situation.  But since I'm not 100% sure what all variations of these you may consider to be either a 'plan' view or an 'elevation' view, and base view isn't specifically in either of these, I'm just using the ones you mentioned.

 

If ThisApplication.ActiveDocumentType <> DocumentTypeEnum.kDrawingDocumentObject Then
	MsgBox("A Drawing Document must be active for this rule to work. Exiting.",vbOKOnly+vbCritical, "WRONG DOCUMENT TYPE")
	Exit Sub
End If
Dim oDDoc As DrawingDocument = ThisApplication.ActiveDocument
Dim oSheet As Inventor.Sheet = oDDoc.ActiveSheet
Dim oSSDefs As SketchedSymbolDefinitions = oDDoc.SketchedSymbolDefinitions
Dim oPlanSymbolName As String = "PLAN VIEW TITLE" '<<<< CHANGE THIS >>>>
Dim oOtherSymbolName As String = "OTHER VIEW TITLE" '<<<< CHANGE THIS >>>>
Dim oTG As TransientGeometry = ThisApplication.TransientGeometry
For Each oView As DrawingView In oSheet.DrawingViews
	'define placement point for sketch symbol in relation to view (bottom center)
	Dim oP2d As Point2d = oTG.CreatePoint2d((oView.Left + (oView.Width / 2)), (oView.Top - oView.Height))
	Select Case oView.ViewType
	Case kStandardDrawingViewType, kDefaultDrawingViewType, kProjectedDrawingViewType, kAuxiliaryDrawingViewType
		'you can also check or filter by oView.Camera.ViewOrientationType
		'use the sketch symbol here for 'Plan' views (base view's should be included, but there is no specific filter just for them)
		Dim oPlanViewSSDef As SketchedSymbolDefinition
		Try
			oPlanViewSSDef = oSSDefs.Item(oPlanSymbolName)
		Catch
			MsgBox("Couldn't find the " & oPlanSymbolName & "sketch symbol definition.",,"")
			Continue For
		End Try
		Dim oPrompts(1) As String '<<<< CHANGE THIS >>>>
		oPrompts(0) = oView.Name '<<<< CHANGE THIS >>>>
		oPrompts(1) = oView.ScaleString '<<<< CHANGE THIS >>>>
		Dim oSS As SketchedSymbol = oSheet.SketchedSymbols.Add(oPlanViewSSDef, oP2d, 0, 1, oPrompts)
	Case DrawingViewTypeEnum.kDetailDrawingViewType, DrawingViewTypeEnum.kSectionDrawingViewType
		'you can also check or filter by oView.Camera.ViewOrientationType
		'use the sketch symbol here for sections, details & 'elevations'
		'(not sure what your definition of an elevation type view is so I'm not sure how to check for it)
		Dim oSDEViewSSDef As SketchedSymbolDefinition
		Try
			oSDEViewSSDef = oSSDefs.Item(oOtherSymbolName)
		Catch
			MsgBox("Couldn't find the " & oOtherSymbolName & " sketch symbol definition.",,"")
			Continue For
		End Try
		Dim oPrompts(1) As String '<<<< CHANGE THIS >>>>
		oPrompts(0) = oView.Name '<<<< CHANGE THIS >>>>
		oPrompts(1) = oView.ScaleString '<<<< CHANGE THIS >>>>
		Dim oSS As SketchedSymbol = oSheet.SketchedSymbols.Add(oSDEViewSSDef, oP2d, 0, 1, oPrompts)
	End Select
Next

 

Please note, there are several things in there that you will have to change or customize before it will work with your situation.  If you don't want to identify the two source sketch symbols by their names, there are other ways of identifying which one is which.  And if every drawing document doesn't already have those two sketch symbols in them, but they are in a sketch symbol library, we can also use some code to check that, and attempt to bring them into the drawing document from the library first, if needed.  I wasn't sure how many prompted entries you actually had in your symbols, or which order they are in, so I just stuck with two for this code example.  If the sketch symbol has prompted entries, you must specify them and supply that variable to the Add() method, or it will throw an error.  I'm not sure, but I think you also need to supply the correct number of items in that oPrompts array to match how many prompted entries are in that sketch symbol, or it might also throw an error.  The order the prompts are in, directly relates to the sketch definition's Sketch.TextBoxes index order, so the first TextBox (by their Item Index #'s) in the TextBoxes collection, that is for a Prompted Entry, will be the first Prompted Entry value you need to put into the oPrompts array, so they match up.  I hope this helps out some.


Or, if this helped you, please click (LIKE or KUDOS) 👍.

If you want and have time, I would appreciate your Vote(s) for My IDEAS 💡or you can Explore My CONTRIBUTIONS

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes