Replace sketch block A with sketch block B via iLogic in .dwg

Replace sketch block A with sketch block B via iLogic in .dwg

darrell.wcd
Enthusiast Enthusiast
750 Views
1 Reply
Message 1 of 2

Replace sketch block A with sketch block B via iLogic in .dwg

darrell.wcd
Enthusiast
Enthusiast

I have a bunch of drawings that have sketchblockA placed on them. Its in the correct place, but I need to change them all out with sketchblockB. 

 

I will trigger this on-open, and I need to be able to iterate through each sheet in the .dwg drawing and if it has sketchblockA then replace with sketchblockB and if not sketch block, then add sketchblockB in specific location, and if possible snap it to bottom left corner of the title block as shown below. I have found snips of ilogic related to placing sketch blocks but cant find any that will do what I want. If a pro would have some suggestions, samples or the actual code would be great.

 

 Bottom left corner of title blockBottom left corner of title block

0 Likes
Accepted solutions (1)
751 Views
1 Reply
Reply (1)
Message 2 of 2

Sergio.D.Suárez
Mentor
Mentor
Accepted solution

Hi, try with this rule.
  this rule will search for a specific name every sketchSymbolA and replace it with another sketchSymbolB. Place the second symbol in the same position as the first symbol. You must not have text entry so you can perform the replacement.

Dim SymbolA_Name As String = "sketchblockA"   '''Existing symbol on the sheet to replace
Dim SymbolB_Name As String = "sketchblockB"   ''' New Symbol

Dim oDoc As DrawingDocument = ThisDoc.Document
Dim oSymbolB_Def As SketchedSymbolDefinition
oSymbolB_Def = oDoc.SketchedSymbolDefinitions.Item(SymbolB_Name)

Dim oSheets As Sheets
oSheets = oDoc.Sheets
For Each oSheet In oSheets
	For Each oSymbolA As SketchedSymbol In oSheet.SketchedSymbols
		If oSymbolA.Name = SymbolA_Name Then 
' Add an instance of the sketched symbol definition to the sheet. Rotate angle = 0 radians,scale = 1 when adding, no prompt text
			Dim oSymbolB As SketchedSymbol
			oSymbolB = oSheet.SketchedSymbols.Add(oSymbolB_Def, oSymbolA.Position, 0, 1, Nothing)
			oSymbolA.Delete
		End If
	Next
Next

 I hope the rule is useful for you. regards


Please accept as solution and give likes if applicable.

I am attaching my Upwork profile for specific queries.

Sergio Daniel Suarez
Mechanical Designer

| Upwork Profile | LinkedIn