Create sketch in machining

Create sketch in machining

Anonymous
Not applicable
488 Views
5 Replies
Message 1 of 6

Create sketch in machining

Anonymous
Not applicable

I am trying to create a sketch in machining in a sub-weldment assembly with a ilogic code. But i continuously get this error:Clipboard06.jpg

Here is the code i am running from an external rule.Can anyoone help please??

 



Dim
oDoc As Document oDoc = ThisApplication.ActiveEditDocument If oDoc.DocumentType = DocumentTypeEnum.kAssemblyDocumentObject If Not oDoc.ComponentDefinition.IsiAssemblyFactory Then If oDoc.ComponentDefinition.Type = objectTypeEnum.kWeldmentComponentDefinitionObject Then 'Keep Selecting Faces, Hit Esc to finish Do oFace = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kAllPlanarEntities, "Select a face") If Not oFace Is Nothing Then Exit Do End If Loop While Not oFace Is Nothing oDoc.ComponentDefinition.Machining.edit oSketch = oDoc.ComponentDefinition.Sketches.Add(oFace)
oSketch.edit
End if
End if
End if

 

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

Anonymous
Not applicable

Anyone?

0 Likes
Message 3 of 6

Sergio.D.Suárez
Mentor
Mentor

Hi, your code is not wrong in principle. What happens is that when selecting a face you should work with proxies to define in context of which assembly to work in your case in the subassembly. For this reason it returns the error and you would not easily create a sketch.
However, I think the simplest thing is to create a sketch directly with the manager and manager.
Try the code below. It is summarized and simple.

 

Dim oDoc As Document = ThisDoc.Document

Dim oSubAssy As ComponentOccurrence = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kAssemblyOccurrenceFilter, "Select Occurrence")
If oSubAssy Is Nothing Then 
	Exit Sub
End If
	
If oSubAssy.Definition.Type = 100673280 Then '  objectTypeEnum.kWeldmentComponentDefinitionObject
	oSubAssy.Edit
	oSubAssy.Definition.Machining.edit
	'Create Sketch			
	ThisApplication.CommandManager.ControlDefinitions.Item("AppSketch2DWrapperCmd").Execute2(True)   
End If

  I hope it can be useful. 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

0 Likes
Message 4 of 6

Anonymous
Not applicable

 Sergio.D.Suárez If able, can you show me the solution with the proxies or at leaset some code with proxies so i can understand how they are used. I intend to use this code as part of much larger codes.

0 Likes
Message 5 of 6

Sergio.D.Suárez
Mentor
Mentor

Here there is information and in the API you can find more. The code you provide realizes what you are looking for and you will not have problems entering it in another major code. regards

https://adndevblog.typepad.com/manufacturing/2013/07/occurrences-contexts-definitions-proxies.html


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

0 Likes
Message 6 of 6

Anonymous
Not applicable

 I have tried all morning but i just can't get the code right with proxies. Sergio.D.Suárez can you help me with that??

0 Likes