Moldflow Insight Forum
Welcome to Autodesk’s Moldflow Insight Forums. Share your knowledge, ask questions, and explore popular Moldflow Insight topics.
Showing results for 
Show  only  | Search instead for 
Did you mean: 

API scripting for cad surface/Body

Message 1 of 2
99 Views, 1 Reply

API scripting for cad surface/Body

Hi users,
I am developing a script for part orientation, but I am having trouble obtaining the part surface or body via the API for translation and rotation. Is there a way to choose the part surface or body using the API?

Regards and gratitude
Anirudha D.

Message 2 of 2
in reply to: adevadkar


Hi Anirudha,
For part surface predicate could be used as label S for surfaces available
For CAD body / bodies it is not so straight forward.
The reason is that label BD does not exist as label as for surface S.

You could stack BD numbers in entity list, and CAD body only selected if available.
But not 100% selection safe - but might suit your needs?

This code example works for if any CAD body and Surface in study.


Dim SynergyGetter, Synergy
On Error Resume Next
Set SynergyGetter = GetObject(CreateObject("WScript.Shell").ExpandEnvironmentStrings("%SAInstance%"))
On Error GoTo 0
If (Not IsEmpty(SynergyGetter)) Then
	Set Synergy = SynergyGetter.GetSASynergy
	Set Synergy = CreateObject("synergy.Synergy")
End If
Synergy.SetUnits "Metric"
Set LayerManager = Synergy.LayerManager()
Set Modeler = Synergy.Modeler()
Set EntList_BD = Modeler.CreateEntityList()
Set EntList_S = Modeler.CreateEntityList()

Set Vector = Synergy.CreateVector()
Set Vector_1 = Synergy.CreateVector()

'** This does not work, as label BD is not available
'Set PredicateManager = Synergy.PredicateManager()
'Set Predicate1 = PredicateManager.CreateLabelPredicate("BD1:")
'EntList_BD.SelectFromPredicate Predicate1

' select CAD bodies
EntList_BD.SelectFromString " BD1 BD2 BD3 BD4 BD5 BD6 BD7"

' Select all surfaces 
Set PredicateManager = Synergy.PredicateManager()
Set Predicate1 = PredicateManager.CreateLabelPredicate("S1:")
EntList_S.SelectFromPredicate Predicate1

Vector.SetXYZ 41.222, 0, 27.602
Vector_1.SetXYZ 1, 0, 0
Modeler.Rotate EntList_BD, Vector, Vector_1, 90, False, 1, False
Modeler.Rotate EntList_S, Vector, Vector_1, 90, False, 1, False


Raised an enhancement request in Moldflow Ideas.
Moldflow API: Add predicate label for CAD body : BD
Kudos it if you agree.😊


Hope this helps.

( If my comments are accepted, provide "Kudos" as appreciation. If your request is answered/resolved, please click the "Accept as Solution" button. Thanks.)

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Technology Administrators

Autodesk Design & Make Report