MOVE a sketched symbol?

MOVE a sketched symbol?

CadUser46
Collaborator Collaborator
1,249 Views
4 Replies
Message 1 of 5

MOVE a sketched symbol?

CadUser46
Collaborator
Collaborator

I need some help here.  I have a symbol that gets placed in a certian location on a sheet.  If the sheet changes size i would like the symbol to relocate itself.  Usually i could just find it, delete it and replace it but this one is different.  It has 16 prompted entries that may have been populated by the user.

 

Easy option=Be able to move the symbol.

 

Difficult option=Load 16 prompted entries into the a dynamic array and replace save the symbol in the new location.  I would consider this beyond my skills just now so im looking for advice or other suggestions.

 

I did some reading on attributes, would adding an attribute to the sheet location allow the symbol to move with it.

Thanks

 

Craig.


Did you find this reply helpful ? If so please use the Accept as Solution or Kudos button below.

---------------------------------------------------------------------------------------------------------------------------
Inventor 2010 Certified Professional
Currently using 2023 Pro
0 Likes
1,250 Views
4 Replies
Replies (4)
Message 2 of 5

Mike.Wohletz
Collaborator
Collaborator

I don't know how you are planning to do your automation, but below is a sample of getting the sheet size and setting the symbol to a location by that size. It is in VB.NET right now so if you knock off the first and last line it will run in iLogic or it can be converted to VBA if you need. 

 

    Public Sub SymbolRelocate()
        Dim oDrawDoc As DrawingDocument = ThisApplication.ActiveDocument
        Dim oSheet As Sheet = oDrawDoc.ActiveSheet
        For Each oSketchedSymbol As SketchedSymbol In oSheet.SketchedSymbols
            If oSketchedSymbol.Name = "The Symbol you want to move" Then
                Dim oPoint As Point2d = oSketchedSymbol.Position
                Select Case oSheet.Size
                    Case DrawingSheetSizeEnum.k24x36InDrawingSheetSize
                        oPoint.X = 27
                        oPoint.Y = 30
                    Case DrawingSheetSizeEnum.k18x24InDrawingSheetSize
                        oPoint.X = 18
                        oPoint.Y = 21
                    Case Else
                        oPoint.X += 5
                        oPoint.Y += 5
                End Select
                If Not oPoint Is Nothing Then
                    oSketchedSymbol.Position = oPoint
                End If
            End If
        Next
    End Sub

 

0 Likes
Message 3 of 5

CadUser46
Collaborator
Collaborator

Thanks Mike.  Im going to go try this out today.


Did you find this reply helpful ? If so please use the Accept as Solution or Kudos button below.

---------------------------------------------------------------------------------------------------------------------------
Inventor 2010 Certified Professional
Currently using 2023 Pro
0 Likes
Message 4 of 5

CadUser46
Collaborator
Collaborator

Mike this works perfectly but i have one question.  I assume this works because i already have an insertion point in my symbol?  Otherwise how would it would what point im defning in this procedure?


Did you find this reply helpful ? If so please use the Accept as Solution or Kudos button below.

---------------------------------------------------------------------------------------------------------------------------
Inventor 2010 Certified Professional
Currently using 2023 Pro
0 Likes
Message 5 of 5

rschader
Advocate
Advocate

I tool the original code posted above and modified it into an iLogic rule that prompts you for an axis and amount to move sketched symbols, then uses a do loop and CommandManager.Pick to select the symbols to move. It's still kind of basic, but is a big help when you have dozens of symbols that shifted because of a view size change. Works for me in Inventor 2015, so far! Save it to an external rule, name of your choosing (I used SymbolRelocate, same as the original subroutine above. Here is the code:

 

Dim Xoff As Double = 0
Dim Yoff As Double = 0
myparam = InputBox("Enter move amount in centimeters", "Move Amount", "1")
booleanParam = InputRadioBox("Select Axis for Move", "X Axis", "Y Axis", booleanParam, Title := "Title")
If booleanParam = True Then
	Xoff = CDbl(myparam)
	'MessageBox.Show("Distance to Move: " & CStr(Xoff), "Selected Axis: X") 'debug	
Else
	Yoff = CDbl(myparam)
	'MessageBox.Show("Distance to Move: " & CStr(Yoff), "Selected Axis: Y") 'debug
End If

Dim oDrawDoc As DrawingDocument = ThisApplication.ActiveDocument
Dim oSheet As Sheet = oDrawDoc.ActiveSheet
Dim oPoint As Point2d

Dim oSketchedSymbol As SketchedSymbol
Do
    oSketchedSymbol = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kDrawingSketchedSymbolFilter, "Select Sketched Symbol")
    If oSketchedSymbol Is Nothing Then
        Exit Sub
    End If
    oPoint = oSketchedSymbol.Position
    oPoint.X = oPoint.X + Xoff
    oPoint.Y  =oPoint.Y + Yoff
    If Not oPoint Is Nothing Then
        oSketchedSymbol.Position = oPoint
		'MessageBox.Show("Message", "Title")
    End If
Loop 

 Hope someone finds it useful!

0 Likes