Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Alternative of InputTypeObject="AnyObject" 1

Status
Not open for further replies.

makyy

Automotive
Mar 2, 2021
19
0
0
JP
Hello everyone,
I made an intersection macro. The first element is automatically selected while the second element is to be selected by the user.
I tried InputObjectType(0)="AnyObject", but when I select PartBody from my specification tree it ends up in not selecting anything at all.
The code is selecting planes, surfaces ,edges, etc smoothly..

Like in intersection we can select wireframe elements,solid elements and surfaces ,I want the same thing with my macro.Any help will be appreciated.

the code that I created is:
Dim InputObject()
ReDim InputObject(0)
InputObject(0) = "AnyObject"


Dim reference4 As reference
Set reference4 = oPart.CreateReferenceFromObject(hybridShapeFill1)

Dim Status4 As String

Status4 = oSec.SelectElement2(InputObject, _
"Select 2nd element to proceed with intersection。", False)

If (Status4 = "Cancel") Or (Status4 = "Undo") Then
Exit Sub
End If

Dim reference5 As reference
Set reference5 = oSec.Item(1).reference

Dim hybridShapeIntersection1
Set hybridShapeIntersection1 = hybridShapeFactory1.AddNewIntersection(reference4, reference5)

hybridShapeIntersection1.PointType = 0

hybridBody1.AppendHybridShape hybridShapeIntersection1

oPart.InWorkObject = hybridShapeIntersection1

oPart.Update

oSec.Clear
 
Replies continue below

Recommended for you

Well, I'm pretty sure that selection works fine. The problem is how you create Reference objects.
You should use Part.CreateReferenceFromObject pretty much all the time you're working within a part:

Code:
set reference5 = oPart.CreateReferenceFromObject(oSec.Item(1).Value)
 
Thankyou Little Cthullu for the reply...
It works when I select Elements from the specification tree but it does not work when I select the elements directly..
 
I suppose "directly" means "from model viewer".

You need to test if selected item is a generic geometry (edge, face , vertex) and if so use object from .Value directly.

Or you can really use .Reference, it's all about testing what kind of a selection has been made by a user.
 
Status
Not open for further replies.
Back
Top