Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations cowski on being selected by the Eng-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
Joined
Mar 2, 2021
Messages
19
Location
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
 
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.
 
Thankyou Little Cthulhu..
I did use .Reference, and it works fine.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top