Constraining a new part to an existing object in an Assembly

Constraining a new part to an existing object in an Assembly

Anonymous
Not applicable
324 Views
1 Reply
Message 1 of 2

Constraining a new part to an existing object in an Assembly

Anonymous
Not applicable

I'm trying to get my code to select 2 faces and constrain a new part to the two selected faces. I want to do it multiple times and select the part based on which components I pick, hence why I am trying to use ilogic.

 

I've tried looking but I can only find ones where the constraints are with 2 components that have been added to the assembly and not to a component which is already there.

 

Any advice would be appreciated,

Thanks

 

Josh

0 Likes
325 Views
1 Reply
Reply (1)
Message 2 of 2

Anonymous
Not applicable

This is what I've got so far.

 

This is giving me:

Unspecified error (Exception from HRESULT: 0x80004005 (E_FAIL))

Dim oDoc As AssemblyDocument
oDoc = ThisApplication.ActiveDocument
    
Dim oFace As Face
oFace = ThisApplication.CommandManager.Pick(kPartFaceCylindricalFilter, "Select a cylindrical face")
	
Washer = "C:\Autodesk Vault - Workspace\Designs\Parts\Fasteners\Washer\502712.ipt"
obj1 = Components.Add("Washer", Washer, position := Nothing, grounded :=False, visible :=True)
	
Dim namedEntities = iLogicVb.Automation.GetNamedEntities(obj1.Occurrence.ReferencedDocumentDescriptor.ReferencedDocument)
Dim face0 As Face = namedEntities.FindEntity("Face0")

Dim omate As MateConstraint
omate = oDoc.ComponentDefinition.Constraints.AddMateConstraint(oFace, face0, 0, kInferredLine, kInferredLine)
	

 

0 Likes