Sketch symbol & Table creation for QC Inspection

Sketch symbol & Table creation for QC Inspection

b_pasupathy2000salem
Observer Observer
286 Views
6 Replies
Message 1 of 7

Sketch symbol & Table creation for QC Inspection

b_pasupathy2000salem
Observer
Observer

Hi Guys, I'm working on some automation tool for QC Inspection, basically it's purpose was place a symbol with counter to all dimensions and extract these dimensions to table. Now i complete the first step which is place a symbol on dimensions and i struggle with table creation. please anyone guide me to sort this out 

 

b_pasupathy2_0-1756445061556.png

 

Sub Main()
    Dim oDoc As DrawingDocument = ThisDoc.Document
    Dim oSymDef As SketchedSymbolDefinition

    Try
        oSymDef = oDoc.SketchedSymbolDefinitions.Item("Your Sketched Symbol Name")
    Catch ex As Exception
        MsgBox("Sketch Symbol not found: " & ex.Message)
        Exit Sub
    End Try

    Dim counter As Integer = 1
    Dim offsetX As Double = 0.5
    Dim offsetY As Double = 0.2
    Dim oTG As TransientGeometry = ThisApplication.TransientGeometry

    Dim oSheet As Sheet
    For Each oSheet In oDoc.Sheets
        Dim oDims As GeneralDimensions = oSheet.DrawingDimensions.GeneralDimensions

        For Each oDim As GeneralDimension In oDims
            Dim dimPt As Point2d = oDim.Text.Origin

            Dim symPt As Point2d = oTG.CreatePoint2d(dimPt.X + offsetX, dimPt.Y + offsetY)

            Dim oLeaderPoints As ObjectCollection = ThisApplication.TransientObjects.CreateObjectCollection()
            oLeaderPoints.Add(symPt)
            oLeaderPoints.Add(dimPt)

            Dim promptValues(0) As String
            promptValues(0) = counter.ToString()

            Try
                Dim oSketchedSymbol As SketchedSymbol = oSheet.SketchedSymbols.AddWithLeader(oSymDef, oLeaderPoints, 0, 1, promptValues)
                oSketchedSymbol.Static = True
                oSketchedSymbol.LeaderVisible = False
            Catch ex As Exception
                MsgBox("Error placing symbol " & counter & ": " & ex.Message)
            End Try

            counter += 1
        Next
    Next
End Sub

 

0 Likes
Accepted solutions (2)
287 Views
6 Replies
Replies (6)
Message 2 of 7

WCrihfield
Mentor
Mentor
Accepted solution

Hi @b_pasupathy2000salem.  Creating a custom table in a drawing is one things, and definitely possible.  However, gathering the information from all of those sketched symbols and the dimensions that they are supposed to be associated with, is quite another challenge, and I do not believe it would be possible the way you have done things with that rule above.  You are just using simple, transient Point2d objects to specify both of the leader node locations.  That does not create any type of 'association' between the leader note and the dimension.  You need to be using a 'GeometryIntent' for the location where the leader notes pointer is to be 'attached' to the dimension, then put that into the object collection as its first item.  The location for where the text of the leader should be can just be a simple Point2d, and added to the collection after that.

The Inventor.Sheet object containing the dimension and sketched symbol, has the Sheet.CreateGeometryIntent method that you will have to use.  One of the types of 'geometry' that you can supply as the first input into that method is a DrawingDimension type object.  That is the most generic type (base type) that most other types of dimensions in a drawing are derived from, so adding a GeneralDimension will work also, because it is a sub type.  That method also has an optional second input, which can be used for specifying a more specific location along the first specified geometry object, but it is not always necessary to specify that one.  When the sketched symbol is 'attached' to a piece of geometry with a GeometryIntent, that gives the note or sketched symbol access to the properties of the piece of geometry...such as being able to recognize which component a balloon is attached to.

However, accessing the information associated with whatever a leader note or sketched symbol is attached to is a whole other complicated challenge.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 3 of 7

WCrihfield
Mentor
Mentor
Accepted solution

Here is a brief example iLogic rule that will let the user manually select a SketchedSymbol that has been placed on a drawing sheet somewhere, and is attached to a DrawingDimension, and it will dig down through that symbols leader, then its nodes, to hopefully find a GeometryIntent, if it is truly attached to something.  There are all sorts of types of objects that it could be attached to, so it shows you in a pop-up message what type of object it was attached to, if any, but this code only proceeds from there if it is a DrawingDimension, and if that is the case, it will show the text of the dimension in a pop-up message.  I am not sure what aspect of the dimension you were planning on recording to your custom table, but this should give you some hints on how to get to that information.

Dim oSkSybl As SketchedSymbol = ThisApplication.CommandManager.Pick( _
SelectionFilterEnum.kDrawingSketchedSymbolFilter, "Select a SketchedSymbol to inspect.")
If oSkSybl Is Nothing Then Return
Dim oLeader As Inventor.Leader = oSkSybl.Leader
If oLeader.HasRootNode Then
	Dim oRNode As LeaderNode = oLeader.RootNode
	Dim oNodes As LeaderNodesEnumerator = oLeader.AllNodes
	For Each oNode As LeaderNode In oNodes
		If oNode.AttachedEntity Is Nothing Then Continue For
		Dim oGI As Inventor.GeometryIntent = oNode.AttachedEntity
		Dim oGeom As Object = Nothing : Try : oGeom = oGI.Geometry : Catch : End Try
		If oGeom Is Nothing Then Continue For
		MsgBox("TypeName(oGeom) = " & TypeName(oGeom),,"")
		If TypeOf oGeom Is DrawingDimension Then
			Dim oDDim As DrawingDimension = oGeom
			MsgBox(oDDim.Text.Text,,"")
		End If
	Next 'oNode
End If

If this solved your problem, or answered your question, please click ACCEPT SOLUTION .
Or, if this helped you, please click (LIKE or KUDOS) 👍.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 4 of 7

dineshkumar_arumugamYY6PL
Observer
Observer

Hi, @b_pasupathy2000salem I understand what you try to doing from this code. Here i give my code, I'm not sure it's working properly. Maybe you can refer this for your code

 

Sub Main()
Dim oDoc As DrawingDocument = ThisDoc.Document
Dim oSymDef As SketchedSymbolDefinition

Try
oSymDef = oDoc.SketchedSymbolDefinitions.Item("Your Sketched Symbol Name")
Catch ex As Exception
MsgBox("Sketch Symbol not found: " & ex.Message)
Exit Sub
End Try

Dim counter As Integer = 1
Dim offsetX As Double = 0.5
Dim offsetY As Double = 0.2
Dim oTG As TransientGeometry = ThisApplication.TransientGeometry

Dim oSheet As Sheet
For Each oSheet In oDoc.Sheets
Dim oDims As GeneralDimensions = oSheet.DrawingDimensions.GeneralDimensions

For Each oDim As GeneralDimension In oDims
Dim dimPt As Point2d = oDim.Text.Origin

' Create the intent associated with the dimension
Dim oIntent As GeometryIntent = oSheet.CreateGeometryIntent(oDim)

Dim symPt As Point2d = oTG.CreatePoint2d(dimPt.X + offsetX, dimPt.Y + offsetY)

Dim oLeaderPoints As ObjectCollection = ThisApplication.TransientObjects.CreateObjectCollection()
oLeaderPoints.Add(symPt)
oLeaderPoints.Add(oIntent) ' Use the intent as the leader endpoint

Dim promptValues(0) As String
promptValues(0) = counter.ToString()

Try
Dim oSketchedSymbol As SketchedSymbol = oSheet.SketchedSymbols.AddWithLeader(oSymDef, oLeaderPoints, 0, 1, promptValues)
oSketchedSymbol.Static = True
oSketchedSymbol.LeaderVisible = False
Catch ex As Exception
MsgBox("Error placing symbol " & counter & ": " & ex.Message)
End Try

counter += 1
Next
Next
End Sub

0 Likes
Message 5 of 7

b_pasupathy2000salem
Observer
Observer

Hi @WCrihfield Thanks for the help, I'll try this approach to get the dimension data. Once it finished I'll let us know.

0 Likes
Message 6 of 7

Hi @dineshkumar_arumugamYY6PL Thanks for the tip. I'll use this code 

0 Likes
Message 7 of 7

pasupathy_baskar
Contributor
Contributor

@b_pasupathy2000salemI try this with Geometry Intent, but i keep getting errors (I use AI for code) @WCrihfield Could you give any reference or example code for this or any solutions

0 Likes