copy sketched symbols with folders

copy sketched symbols with folders

sripandian
Enthusiast Enthusiast
1,916 Views
9 Replies
Message 1 of 10

copy sketched symbols with folders

sripandian
Enthusiast
Enthusiast

I want to copy a sketched symbols to another drawing without disturbing the structure like following here

Change line,Dim symbols,Stamps are folders in sketched symbol. Code required in C#. Kindly any one help me.

 

Drawing Resources

|-Sheet format

|-Borders

|-Title Blocks

|-Sketch Symbols

    |-Change line         

       |-chanhr JJ

       |-Revison change

    |-Dim symbols

       |-Din Iso1345

       |-Isorrt

   |-Stamps

      |-Stamp2

|

|

|

0 Likes
Accepted solutions (1)
1,917 Views
9 Replies
Replies (9)
Message 2 of 10

MechMachineMan
Advisor
Advisor

1. Write code to copy symbols from a source drawing to a destination drawing.

2. Write code to add the symbols to folders.

 

Is there a reason you require it in C#?

 

If you need it in a specific language it seems to me that you don't know enough about it it to even know where to begin, or that you have the ability to write but are just too lazy to look up in the API and figure out how.


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

Justin K
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization


iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread

Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects

Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help

Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type
0 Likes
Message 3 of 10

sripandian
Enthusiast
Enthusiast
Hi thanks for your reply. I know how to copy sketch symbols. Using .Copyto
method can copy sketch symbols .But it is go to under sketch symbol folder.
For example, few Copied sketch symbol should go to "Changeline" folder
under sketched symbol folder and few other sketched symbol should go to
another folder in a Target drawing. My problem is creating a folders in
target drawing as it is in source drawing. I need exact structure in source
drawing.

I am new to c# program.thats why I mentioned particular language.
0 Likes
Message 4 of 10

MechMachineMan
Advisor
Advisor
Accepted solution

See below. Please note, it has 0 error checking in it currently, so if it is ran in the document more than once (as well as a couple other things), it will cause an error.

 

Also, this is in vb.net, so it is ready to run as an iLogic rule.

 

You have yet to convert it and add error handling.

 

Good luck.

 

'Starting Structure:
'|-Sketch Symbols
'  |- Triangle
'  |- Square
'  |- Ellipse

'Ending Structure:
'|-Sketch Symbols
'  |- Combo
'     |- Ellipse
'     |- Sharps
'        |- Triangle
'        |- Square
      
Sub Main()
	Call AddItemsToFolder("Sharps", "Triangle", "Square")
	Call SortDwgResourcesFolder
	Call AddItemsToFolder("Combo", "Sharps", "Ellipse")
	Call SortDwgResourcesFolder
End Sub

Sub AddItemsToFolder(oFolderTitle As String, ByVal ParamArray oSketchedSymbolNameArray As String())

	Dim oPane As BrowserPane
	Dim oNode As BrowserNode
	Dim oTopNode As BrowserNode
	Dim oDwgResourcesFolder As BrowserNode
	Dim oSketchedSymbolsFolder As BrowserNode
	Dim oOccurrenceNodes1 As ObjectCollection
	
	oOccurrenceNodes1 = ThisApplication.TransientObjects.CreateObjectCollection
	oPane = ThisApplication.ActiveDocument.BrowserPanes("Model")

	oDwgResourcesFolder = oPane.TopNode.BrowserNodes.Item("Drawing Resources")
	oSketchedSymbolsFolder = oDwgResourcesFolder.BrowserNodes.Item(4)
	
	For Each oNode In oSketchedSymbolsFolder.BrowserNodes
		oNodeName = Right(oNode.FullPath, Len(oNode.FullPath) - InStrRev(oNode.FullPath, ":", -1))
		
		For Each oSketchSymbolName In oSketchedSymbolNameArray
			If oNodeName = oSketchSymbolName
				oOccurrenceNodes1.Add(oNode)
			End If
		Next
		
	Next
	
	oPane.AddBrowserFolder(oFolderTitle, oOccurrenceNodes1)
End Sub

Sub SortDwgResourcesFolder()

	ThisApplication.ActiveDocument.BrowserPanes("Model").TopNode.BrowserNodes.Item("Drawing Resources").BrowserNodes.Item(4).DoSelect
	
	Dim oCommandMgr As CommandManager
	oCommandMgr = ThisApplication.CommandManager
	
	Dim oControlDef1 As ControlDefinition
	oControlDef1 = oCommandMgr.ControlDefinitions.Item("DrawingResourceSort")
	oControlDef1.Execute
End Sub

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

Justin K
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization


iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread

Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects

Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help

Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type
Message 5 of 10

MechMachineMan
Advisor
Advisor

In your case, I guess it's as easy as:

 

Call AddItemsToFolder("Stamps", "Stamp2")
Call AddItemsToFolder("Dim Symbols", "Din Iso1345", "Isorrt")
Call AddItemsToFolder("Change Line", "chanhr JJ", "Revison change")

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

Justin K
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization


iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread

Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects

Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help

Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type
0 Likes
Message 6 of 10

sripandian
Enthusiast
Enthusiast
Hi thank you so much for help me to find solution.
I tried ur code it just create a folder above Drawing Resource folder not
in sketch symbol folder.
I need to copy a sketch symbol from source drawing and place it in a
particular folder under sketch symbol folder like in source drawing file.

In above example, In source drawing the folder structure is
Sketch Symbols
|-Change line
|-chanhr JJ
|-Revison change
|-Dim symbols
|-Din Iso1345
|-Isorrt
|-Stamps
|-Stamp2
Change Line is a folder under sketch symbol folder.chanhr, Revision change
are sketch symbols need to use it in a drawing kept in Change Line folder.

Dim symbols is another folder under Sketch symbol folder.Din Iso
1345,Isorrt are Sketch symbols.

Stamps is another folder under Sketch symbol folder.Stamp2 is sketch symbol
inside in Stamp folder.

All sketch symbols i can copy and move to target drawing. But maintain a
structure like in a source drawing only will be issue.


0 Likes
Message 7 of 10

MechMachineMan
Advisor
Advisor

No, the code should work properly.

 

Can you post a picture of what the browser looks like after you ran the rule, and also paste your version on my code?


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

Justin K
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization


iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread

Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects

Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help

Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type
0 Likes
Message 8 of 10

sripandian
Enthusiast
Enthusiast

Capture1.JPG pls look here change Lines folder created under file name. it doesn't have the sketch symbols too..

0 Likes
Message 9 of 10

MechMachineMan
Advisor
Advisor

Ok. Yes, something is definitely off there

 

I retested my code and it works 100% fine on my computer.

 

Can you post the code that you used for to make it add the folders?

 

Really, the only reason it should be adding it to the top level like that is if you changed some of the code within the helper procedure or if there is something buggy about your application.


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

Justin K
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization


iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread

Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects

Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help

Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type
Message 10 of 10

sripandian
Enthusiast
Enthusiast

Hi,

 

Thanks man.Finally got it. I made a mistake. Correct it now. Code which you gave works fine.Thanks lot. trying to copy sketch symbol not in target drawing, it is in Source drawing in my code.That is the reason it didn't comes under the sketch symbol folder.once added the sketch symbol created folder added under sketched symbol folder. 

 

0 Likes