Ilogic: Add all weldment parts automatically to drawing?

Ilogic: Add all weldment parts automatically to drawing?

Ivil
Enthusiast Enthusiast
963 Views
7 Replies
Message 1 of 8

Ilogic: Add all weldment parts automatically to drawing?

Ivil
Enthusiast
Enthusiast

Hi!

We use multiple details to one drawing, and we are using are placing our parts from Model state>Weldment preparation. This works out well for us , and all parts get a uniqe item number. What i´m looking for is if someone has made a ilogic script to add the first view of all parts automatically. This should make our drawing generation much quicker. 

It´s not important to have views tidy, just that all parts are generated. Thanks /Andreas

Accepted solutions (1)
964 Views
7 Replies
Replies (7)
Message 2 of 8

dutt.thakar
Collaborator
Collaborator
Accepted solution

@Ivil 

Are you looking for something like this?

 

Dim oDoc As DrawingDocument = ThisApplication.ActiveDocument

Dim oSheet As Sheet = oDoc.ActiveSheet
Dim doc As AssemblyDocument = ThisDrawing.ModelDocument
'doc = ThisDrawing.ModelDocument

Dim i As Integer = 0

Dim oOcc As ComponentOccurrence

For Each oOcc In doc.ComponentDefinition.Occurrences
	
	If oOcc.DefinitionDocumentType = DocumentTypeEnum.kPartDocumentObject
		MessageBox.Show(oOcc.Name)
		Dim oPT2d As Point2d = ThisApplication.TransientGeometry.CreatePoint2d(i,i) ' to change the placement with coordinates
		Dim oView As DrawingView = oSheet.DrawingViews.AddBaseView(doc,oPT2d,1,ViewOrientationTypeEnum.kFrontViewOrientation,DrawingViewStyleEnum.kHiddenLineDrawingViewStyle)
		oView.SetWeldmentState(WeldmentStateEnum.kPreparationsWeldmentState, oOcc)
		i = i+1
	End If
Next

 You need to adjust the scale (1 in Bold, which you can change) and placement as per your requirement. 

 

Hope this will be helpful.

If this answer has solved your problem please ACCEPT SOLUTION and hit like if you found it helpful..!


Regards,
Dutt Thakar
LinkedIn
Message 3 of 8

SevInventor
Advocate
Advocate

Thanks, this helps me a lot. Is it possible to add each component only once if there are many Occurrences of the same part?

 

 

0 Likes
Message 4 of 8

Ivil
Enthusiast
Enthusiast

Wow! So great! Thank you so much!

0 Likes
Message 5 of 8

dutt.thakar
Collaborator
Collaborator

@Ivil 

Can you accept the answer as a solution? , so that other users know that it is solved and helpful for everyone in the future.

 

 

If this answer has solved your problem please ACCEPT SOLUTION and hit like if you found it helpful..!


Regards,
Dutt Thakar
LinkedIn
0 Likes
Message 6 of 8

Ivil
Enthusiast
Enthusiast

I agree with severin.hainbuchner that it would be great to have it only put out one instace of a part to the drawing. Would be super helpful.

 

I don´t know if you are a deveoper for Autodesk or a regular user?

 

Other things to wish for:

-Auto ballon woud be great

-Put views outside the drawing (not stacked would be preferd)

 

You have solved one of the limitations of "Inventors one part per drawing mindset". I hope that this can evolve and make inventor even better for several parts per drawing! Thank you!

Message 7 of 8

dutt.thakar
Collaborator
Collaborator

@Ivil and @SevInventor 

 

A quick and dirty solution I would say, to not get the multiple views for the same part, but is only applicable if you are not changing the browser node names, as soon as you change browser node names, this will not work, (that is why I am stating a quick and dirty solution)

 

See below code.

 

Dim oDoc As DrawingDocument = ThisApplication.ActiveDocument

Dim oSheet As Sheet = oDoc.ActiveSheet
Dim doc As AssemblyDocument = ThisDrawing.ModelDocument
'doc = ThisDrawing.ModelDocument

Dim i As Integer = 0

Dim oOcc As ComponentOccurrence

For Each oOcc In doc.ComponentDefinition.Occurrences
	
	If oOcc.DefinitionDocumentType = DocumentTypeEnum.kPartDocumentObject And oOcc.Name.Contains(":1") Then
		MessageBox.Show(oOcc.Name)
		Dim oPT2d As Point2d = ThisApplication.TransientGeometry.CreatePoint2d(i,i) ' to change the placement with coordinates
		
				
		Dim oView As DrawingView = oSheet.DrawingViews.AddBaseView(doc, oPT2d, 1, ViewOrientationTypeEnum.kFrontViewOrientation, DrawingViewStyleEnum.kHiddenLineDrawingViewStyle)
		oView.SetWeldmentState(WeldmentStateEnum.kPreparationsWeldmentState, oOcc)
		i = i+1
	End If
Next

 

If this answer has solved your problem please ACCEPT SOLUTION and hit like if you found it helpful..!


Regards,
Dutt Thakar
LinkedIn
Message 8 of 8

A.Acheson
Mentor
Mentor

@Ivil 

The auto balloon and auto dimension are a very involved process. They require each face or edge that needs an annotation to be named in the model space. Then each named face needs to be loaded into the code. If the parts get turned off you need to code that scenario in to, too hide the dimension. I am sure practices makes perfect. There is examples on this forum and from API help. 

Regarding the view placement if you target this area shown below. You can position the views where you like, the same principle applies for parts list, revision boxes, tables, symbols etc. The position can also set after placement.

Dim oPT2d As Point2d = ThisApplication.TransientGeometry.CreatePoint2d(i,i) ' to change the placement with coordinates

You will find examples on this forum.

 

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