Placing & Updating iLogic Sketch Symbols

Placing & Updating iLogic Sketch Symbols

H4TSDESQ
Enthusiast Enthusiast
243 Views
3 Replies
Message 1 of 4

Placing & Updating iLogic Sketch Symbols

H4TSDESQ
Enthusiast
Enthusiast

I'm following up on a post I made a few years ago that dealt with adding a views scale to a predefined Sketch Symbol and I've begun to expand on it a bit more. POST

 

Currently when ran it places my sketch symbols at a set distance from the view at the location I specify and has dummy text preset for the Prompted Entries that exist within the Symbol. I haven't been able to find a way to show the order in which they were placed, so getting prompts to enter in titles without knowing what view you're naming isn't super useful.

 

What I'm hoping to achieve is 3 additional things. 

 

  1. When ran it would check the views that already have a symbol and update the info if it changed (view name, scale, etc)
  2. If ran multiple times it would not place the Sketch Symbol multiple times, simply update only?
  3. Is there a way to have linework within the symbol change as a result of the view width?

 

For point 3, the line beneath "DRAWING AREA TITLE" needs to be the same length as the view, rounded up to the nearest 3/4"

Sections/Details/ElevationsSections/Details/Elevations

PlansPlans

 

Code:

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 = "014200-001 Drawing Area Title - 02 Grids" '<<<< CHANGE THIS >>>>
Dim oOtherSymbolName As String = "014300-001 Drawing Area Title - 02 Grids" '<<<< 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 Left of the view)
    Dim oP2d As Point2d = oTG.CreatePoint2d((oView.Left), (oView.Top - oView.Height))
    Select Case oView.ViewType
    Case kStandardDrawingViewType, kDefaultDrawingViewType, kProjectedDrawingViewType, kAuxiliaryDrawingViewType
        ' Plan view symbol for standard, default, projected, and auxiliary views
        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(7) As String '<<<< CHANGE THIS >>>>
        oPrompts(0) = "X#" '<<<< CHANGE THIS >>>>
		oPrompts(1) = "DRAWING AREA TITLE" & oView.Name '<<<< CHANGE THIS >>>>
        oPrompts(2) = "SCALE" & oView.ScaleString '<<<< CHANGE THIS >>>>
		oPrompts(3) = "SUBTEXT - LINE 1" '<<<< CHANGE THIS >>>>
		oPrompts(4) = "SUBTEXT - LINE 2" '<<<< CHANGE THIS >>>>
		oPrompts(5) = "SUBTEXT - LINE 3" '<<<< CHANGE THIS >>>>
		oPrompts(6) = "SUBTEXT - LINE 4" '<<<< CHANGE THIS >>>>
		oPrompts(7) = "SUBTEXT - LINE 5" '<<<< CHANGE THIS >>>>
		        oSheet.SketchedSymbols.Add(oPlanViewSSDef, oP2d, 0, 1, oPrompts)
    Case DrawingViewTypeEnum.kDetailDrawingViewType, DrawingViewTypeEnum.kSectionDrawingViewType
        ' Section/detail views symbol for sections, details, etc.
        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(9) As String '<<<< CHANGE THIS >>>>
        oPrompts(0) = "Ref Grid" '<<<< CHANGE THIS >>>>
		oPrompts(1) = "Ref Sheet" '<<<< CHANGE THIS >>>>
		oPrompts(2) = "X#" '<<<< CHANGE THIS >>>>
		oPrompts(3) = "DRAWING AREA TITLE" & oView.Name '<<<< CHANGE THIS >>>>
        oPrompts(4) = "SCALE" & oView.ScaleString '<<<< CHANGE THIS >>>>
		oPrompts(5) = "SUBTEXT - LINE 1" '<<<< CHANGE THIS >>>>
		oPrompts(6) = "SUBTEXT - LINE 2" '<<<< CHANGE THIS >>>>
		oPrompts(7) = "SUBTEXT - LINE 3" '<<<< CHANGE THIS >>>>
		oPrompts(8) = "SUBTEXT - LINE 4" '<<<< CHANGE THIS >>>>
		oPrompts(9) = "SUBTEXT - LINE 5" '<<<< CHANGE THIS >>>>
        oSheet.SketchedSymbols.Add(oSDEViewSSDef, oP2d, 0, 1, oPrompts)
    End Select
Next


'Trigger this script by using iTrigger
trigger = iTrigger0

 

0 Likes
244 Views
3 Replies
Replies (3)
Message 2 of 4

WCrihfield
Mentor
Mentor

Hello again @H4TSDESQ.  I have learned a lot about prompted entries since that other conversation a few years ago, but still do not really rely on them for many things myself...just a few uncommonly used sketched symbols in a drawing here and there.  I have several code based tools for digging into all three main types of drawing based objects that commonly have prompted entries defined within them, and getting their Index positions and prompt names, as well as their current values, if inspecting an instance that has already been placed on the sheet.  However, these code tools are mostly in the form of custom Functions, which we can supply one of these types of objects to, and get the entire collection of prompts returned as something like a NameValueMap or Dictionary (both are 2-factor collections, where each 'entry' has two parts).  These are more help with editing existing (already placed) instances, than for filling in prompts before they are initially placed.  But I do have one for retrieving just the prompts and their Indexes from the 'definitions' of those types of objects, for preemptively figuring out how many prompts it has, and what order they are in.

 

However, all three new goals you mentioned above rely on us being able to check if a view already has a sketched symbol associated with it, and being able to get that object, then checking its contents against the view.  Well, the way your code is 'placing' them, there will not be any connection or link between any view and any sketched symbol.  They are just being placed 'near' a view, but not actually 'attached' to anything in the view.  All sketched symbols are capable of having a 'Leader', whether you choose to make it visible in the drawing or not.  That leader can be attached to some type of geometry in the view when placed, then the leader's visibility can be turned off, if you do not want to see it in the drawing.  This is useful, because it will also cause that sketched symbol to move with the view if it is moved or resized.  However, if you have already attached a sketched symbol to some geometry in a view, then the view changes in a way that causes the geometry it was attached to to no longer be included in the view, it will cause an error.  Adding the code needed for including a leader, and specifying its leader nodes, would certainly increase the size and complexity of your code though.  But if done that way, we can iterate through the sketched symbols, and check their leaders, and their leader nodes, and find the node that is 'attached' to something with a GeometryIntent, and inspect that further to find the piece of drawing view geometry, then get its parent drawing view.  Its a relatively complex process, but at least its something to go by.  The GeometryIntent object is what defines the connection/attachment between things like dimensions to things like drawing view geometry.  Other wise you would just have to inspect the contents of each sketched symbol on the sheet in an attempt to get the name of the view it is supposed to be for, and hope its name has not been changed.  Then try to find the drawing view with that view name.  Again, likely not impossible, but not super easy either.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 3 of 4

H4TSDESQ
Enthusiast
Enthusiast

When you say attached are you referring to how if the view is moved the symbol goes with it? Because as it currently is, that is what happens. 

0 Likes
Message 4 of 4

WCrihfield
Mentor
Mentor

Not exactly.  The symbol moving with the view is one of the benefits of attachment, but not the only way to cause it to move with the view.

With the task in mind of being able to find an association between a drawing view and a sketched symbol, I will try to explain.

In your original code above, there are two things being used to place the symbol.  The first is a Point2d (which is just temporary, transient, mathematical data).

Dim oP2d As Point2d = oTG.CreatePoint2d((oView.Left), (oView.Top - oView.Height))

It properties of the view being used there (DrawingView.Left, DrawingView.Top, & DrawingView.Height) only return numerical values (Double) pertaining to location on the sheet in X & Y coordinates, not any real 'connection' or 'association' with the view that will persist.  The Point2d object is just used to temporarily transport those two numerical values, in an organized manner, to their destination, then it will cease to exist.  Then you use that Point2d object within the SketchedSymbols.Add method.  That sets the value of the SketchedSymbol.Position property of the resulting new SketchedSymbol.  When you look at all the properties and methods of that SketchedSymbol object, none of them point directly to any DrawingView, because they can be used for all sorts of things that may have nothing to do with a drawing view.  Even the SketchedSymbol.Parent property only points to the Sheet object that the symbol was placed on, not to a drawing view.  And the SketchedSymbol.Position property only returns a Point2d object, which itself only has 2 properties (X & Y), neither of which are associated in any way to a drawing view.  Therefore, since the sketched symbol was not added with a leader, there is no direct or clear way to find an association with a drawing view from a sketched symbol.

 

Now, if you had used the SketchedSymbols.AddWithLeader method, you would have had to supply an ObjectCollection which contained either one, or possibly multiple Point2d objects, and possibly a single GeometryIntent object, which would be used to define the locations of the leader points.  Yes, it is possible to include only one or multiple Point2d objects, without a GeometryIntent, but then it would not truly be 'connected/linked' with anything.  As I said before, the GeometryIntent object is what defines the connection between things like annotations, and actual model geometry.  They can be created using the Sheet.CreateGeometryIntent method (where the Sheet is the Parent Sheet of the object).  The first thing that method asks for is 'geometry', which can be any of several different types of things ("DrawingCurve, sketch entities from a sheet sketch, DrawingDimension, Centerline, and Centermark objects").  That method also asks for a second input that is Optional, but is sometimes needed anyways, depending on the situation.  The DrawingCurve type object can be obtained from within the collection of them that you get from the DrawingView.DrawingCurves property.  That property works sort of like a Function, where you can optionally supply an item from within the model document, and it will only return the drawing curves that are present in that view for that one item, if any.  One of the possible types of values you could supply for the second argument when creating a GeometryIntent is a variation of the PointIntentEnum.

 

When the sketched symbol has been added with leader, and that leader's nodes included a GeometryIntent, then we can look into the SketchedSymbol.Leader property to get the actual Leader object. Then we can can get the last LeaderNode object in the Leader.AllNodes property value.  Then we can check its LeaderNode.AttachedEntity property value, which should return the GeometryIntent object that was used to attach the leader to the drawing view geometry.  If its GeometryIntent.IntentType is IntentTypeEnum.kGeometryIntent, then the GeometryIntent.Geometry property should return a usable value (instead of Nothing).  What we actually get from that property can be many different types of things, which is why is is defined as a generic Object type.  However, we can check what Type it is, and if something like a DrawingCurve, we can use its DrawingCurve.Parent property to get its parent DrawingView object.  And that's about the only way to find a true connection between a sketched symbol and a drawing view.

Whew. 😅

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes