Macro to create shop drawings from Weldment assembly

Macro to create shop drawings from Weldment assembly

aprajapati3C
Advocate Advocate
450 Views
5 Replies
Message 1 of 6

Macro to create shop drawings from Weldment assembly

aprajapati3C
Advocate
Advocate

We are a fabrication company and we do not issue any shop drawings with weld prep details. We just issue GA drawings with lots of views, dimensions and weld symbols that are required for fabrication. The workshop is experienced enough to interpret this drawing without need of shop details.

 

Now we are expanding and the new workshop needs the shop drawings. So are looking into an option to auto generate shop detail drawings from any particular assembly.

 

I dont know coding. When needed, i search on the forum any copy it. I didnt find anything close to what i am planning to do.

 

The ideal workflow would be as follows,

- Create assemblies with frame generator. And some other parts such as gussets, brackets, clamp plates, etc.

- Convert this assembly to weldments.

- Add weld preparations (Weld gaps, chamfers, etc.)

- Run a macro which creates drawing (3 views) of each part in different sheets of single dwg file.

- Then may be manually give dimensions as needed.

 

I remember few years back i found a macro which created view rep / LOD of each unique part. Not able to find that anymore.

 

Any help or guidelines on above will be appreciated.

0 Likes
451 Views
5 Replies
Replies (5)
Message 2 of 6

A.Acheson
Mentor
Mentor

The best place to start working on this project would be to review the API sample codes in the help file. The primary language is VBA so you can paste the code sub routines directly into the editor and run them for testing. If you are more familiar with the ilogic editor you will need to convert from VBA as the editor uses ilogic and VB.Net languages. 

Being able to navigate around the help file will be helpful as you try and piece together operations to suit your workflow. You may find partially complete code samples on this forums but it will take a little searching and with the right keywords. 

API samples Links

Add BaseView With Representations

Add Sheet Using SheetFormat

 

Add base view sample converted. 

'Conversion of the language from from VBA to VB.Net
'1.Delete the word Set 
'2.Create the starting sub routine Sub Main and add the call for the sub routine
'3.Add in any variables required to sub routine in this case sPath or hardcode this in as needed. 
'4.Comment sections of code not required for initial testing e.g oBaseViewOptions below. These can be added in later as required


Sub Main
	sPath = InputBox("Prompt", "FullFilePath", "Enter a Path of an assembly")

	AddBaseViewWithRepresentations(sPath)
End Sub

Public Sub AddBaseViewWithRepresentations(sPath)
  '  a reference to the drawing document.
  ' This assumes a drawing document is active.
  Dim oDrawDoc As DrawingDocument
   oDrawDoc = ThisApplication.ActiveDocument

  ' a reference to the active sheet.
  Dim oSheet As Sheet
   oSheet = oDrawDoc.ActiveSheet

  ' Create a new NameValueMap object
  Dim oBaseViewOptions As NameValueMap
   oBaseViewOptions = ThisApplication.TransientObjects.CreateNameValueMap

'  '  the representations to use when creating the base view.
'  Call oBaseViewOptions.Add("PositionalRepresentation", "MyPositionalRep")
'  Call oBaseViewOptions.Add("DesignViewRepresentation", "MyDesignViewRep")
'  Call oBaseViewOptions.Add("DesignViewAssociative", True)

  ' Open the model document (corresponding to the "MyLODRep" representation).
  Dim strFullDocumentName As String
  strFullDocumentName = ThisApplication.FileManager.GetFullDocumentName(sPath)', "MyLODRep"

  Dim oModel As Document
   oModel = ThisApplication.Documents.Open(strFullDocumentName, False)

  ' Create the placement point object.
  Dim oPoint As Point2d
   oPoint = ThisApplication.TransientGeometry.CreatePoint2d(25, 25)

  ' Create a base view.
  Dim oBaseView As DrawingView
   oBaseView = oSheet.DrawingViews.AddBaseView(oModel, oPoint, 2, _
  kIsoTopLeftViewOrientation, kHiddenLineRemovedDrawingViewStyle, _
      , , oBaseViewOptions)
End Sub

 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
0 Likes
Message 3 of 6

aprajapati3C
Advocate
Advocate

Thanks @A.Acheson. I am not really familiar with coding. I usually search for codes and use it as it is. Never tried to edit it. But this will be good start to start learning basic VBA.

 

Can you guide from i can learn VBA. I just want focus on the Inventor related coding (if there is such  a thing)

0 Likes
Message 4 of 6

A.Acheson
Mentor
Mentor

Are you familiar with using macros in VBA or with ilogic/VB.NET? You will need to make a decision which language you prefer at least while starting out. VBA is how the help samples are written but really you can use either one. ilogic/VB.NET will allow easier forms to be built to display information, easier for making on the fly modifications etc but can be harder to debug problems. VBA is better at debugging and can highlight a specific line that may be at fault although you cannot use pure ilogic snippets of code in this environment so no shortcutting is allowed. 

 

I think a lot of us have started with the copy and paste methods from the forums and hope for the best, exactly the way I started. To be successful you will have to graduate so to speak to modify and tailor what you have to what you need for the workflow your developing. Really the best place to learn is this forum and to try out a piece of code and try and follow the code line by line and write down what they do. If you encounter problems you cannot solve after a couple of attempts it is good then to post on the forum for help diagnosing what is wrong. If someone else has written in help notes in the sample your using then you have a good head start.  The API help file have lots of samples under specific headings assembly, parts etc. This is the bases for Inventor related coding. These samples have help lines written in as a sort of instruction as to what each line is doing.  

 

AAcheson_0-1653408548974.png

 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
0 Likes
Message 5 of 6

aprajapati3C
Advocate
Advocate

Thanks @A.Acheson. Coding is very alien to me. I need to search for video tutorial that explains the basics of VBA, what are the commands, what it means, etc. 

0 Likes
Message 6 of 6

A.Acheson
Mentor
Mentor

Here is a few links. I am sure you will find many more. I would suggest try out simple operation  in both and see which one you prefer. I went the route of learning ilogic/vb.net first then slowly learn vba also. If you learn both then you have the best of both worlds. 

Ilogic has the handy snippets in the editor so that is a plus. 

 

VBA
https://youtu.be/2ZnR8xBMBpg
https://youtu.be/MFU_QaGdIDA

Ilogic /vb.net
https://youtu.be/DK2tF5mGyXc
https://youtu.be/jjJXmrqtjKs

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
0 Likes