Macro Request (Lock Rotation)

I'm in need of a quick and dirty macro.

I would love to do this myself but currently am way behind...

 

What i'd like is to select item(s) in the Assy pathfinder then run the macro.

 

the macro will traverse each selected items relatioships and for each axial relationship found it will lock the rotation.

 

Thats it.  no error handeling...  no ui.  just a cmd propt exe.

 

Any takers.  or anyone have this already.

 

I use a lot of copy componants..  and currently this does not maintian locked rotation.

 

so when coping hardware i'd like to select the hardware and run the macro to lock all rotations...

 

@Tushar ?  I know you've asked for some simple ideas.  thsi would be very useful.

 

 

 

11 REPLIES

Re: Macro Request (Lock Rotation)

Phenom
Phenom

One of the first macro I wrote many years ago do exactly what you are asking.

 

I'm not sure if it still works, but it should.

 

In attachment the source code too.

Re: Macro Request (Lock Rotation)

Phenom
Phenom

The macro itself is pretty simple:

 

Private Sub Main()
Dim objApp As SolidEdgeFramework.Application
Dim objAsm As SolidEdgeAssembly.AssemblyDocument

On Error Resume Next

Set objApp = GetObject(, "SolidEdge.Application")
Set objAsm = objApp.ActiveDocument

If Err Then
Err.Clear
End
End If

Count = objAsm.SelectSet.Count
If Count = 0 Then
End
Else
For i = 1 To Count
Count3D = objAsm.SelectSet(i).Relations3d.Count
For j = 1 To Count3D
If objAsm.SelectSet(i).Relations3d(j).FixedRotate = False Then
objAsm.SelectSet(i).Relations3d(j).FixedRotate = True
End If
Next
Next
End If

Set objApp = Nothing
Set objDoc = Nothing

End Sub

Re: Macro Request (Lock Rotation)

Phenom
Phenom

Very clean code Francesco.

I too prefer writing quick-and-dirty, no-frills code, safely assuming that the user agrees to use it in just the manner it is supposed to be. Else, there is no end to including those Try-catch blocks, eating up time to no avail.

 

~Tushar

www.SurfAndCode.in

 

Re: Macro Request (Lock Rotation)

Thank you very much!!!

 

Perfect

Re: Macro Request (Lock Rotation)

Phenom
Phenom

Now if Solid Edge wanted to be really be helpful... they'd allow you to also select the LOCK "ANGLE" position as well when using the existing command.

 

I use the LOCK Rotation relationship a lot when placing Air fittings or other hardware that's NOT symmetrical and needs a fixed direction. However Solid Edge only "locks" it in one default position, which always seems to be going in the wrong way. So I'm forced to un-lock it and add a 3rd ANGLE relationship.

 

But wouldn't it be nice if when placing a LOCK Rotation relationship, you could also define the Angle degree from the default position as (1° to 360°)

 

Bob's 2 cents!

Re: Macro Request (Lock Rotation)

Legend
Legend

@BobMileti

That is a great idea. If you have not symmetrical parts, the default position is false for nearly 95% of the parts ;-)

Greetings from Germany
Christian Kunkel
https://c-k-m.info

Re: Macro Request (Lock Rotation)

Phenom
Phenom

BobMileti wrote:

Now if Solid Edge wanted to be really be helpful... they'd allow you to also select the LOCK "ANGLE" position as well when using the existing command.

 

I use the LOCK Rotation relationship a lot when placing Air fittings or other hardware that's NOT symmetrical and needs a fixed direction. However Solid Edge only "locks" it in one default position, which always seems to be going in the wrong way. So I'm forced to un-lock it and add a 3rd ANGLE relationship.

 

But wouldn't it be nice if when placing a LOCK Rotation relationship, you could also define the Angle degree from the default position as (1° to 360°)

 

Bob's 2 cents!


Do you have an ER number to jump on ?

 

Re: Macro Request (Lock Rotation)

Phenom
Phenom

Fiorini,

 

I just put it up on GTAC.... once I have the number I'll post it.

 

Bob

Re: Macro Request (Lock Rotation)

Phenom
Phenom

OK,

 

My Idea was proposed back in 2004.... so my request was added to  ER 5096754