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

validation message for selection of injection location

5 REPLIES 5
SOLVED
Reply
Message 1 of 6
bhavna.kuklani
727 Views, 5 Replies

validation message for selection of injection location

In vbs I want to check if the runner system is generated

RunnerGen = Synergy.RunnerGenerator() and give the validation as No gates or injection locations were found. Cannot generate runner system.

If the injection location is not selected

5 REPLIES 5
Message 2 of 6

Hi Bhavna Kuklani!

 

Thank you for visiting the Moldflow Insight Forums! 

 

If I understand your question correctly, you would like to create a vbs script to check if the runner system if generated?

 

The RunnerGen = Synergy.RunnerGenerator() script that you referenced is actually used to generate a runner system for your model:

script.jpg

 

 

Are you seeing a message that states No gates or injection locations were found. Cannot generate runner system?  

 

 

Thank you,

 

 



Beth Mollica


_______________________________________________________________________________
If my post answers your question, please click the "Accept as Solution" button. This helps everyone find answers more quickly!

Beth
-----------------
If my post answers your question, please click the "Accept as Solution" button. This helps everyone find answers more quickly!



Beth Mollica
Technical Support Specialist
Message 3 of 6

Actually I am automating all the steps so would like this message to be set in vbs msgbox if we do not assign Injection location in mold flow

Therefore wanted to validate the injection location

 

Message 4 of 6

To confirm, you are using the RunnerGen = Synergy.RunnerGenerator() to generate a runner system for your model, but you would like a message included in the vbs msgbox stating something like "No gates or injection locations were found. Cannot generate runner system”  If you do not assign an injection location correct?

 

If I have captured your request correctly, I would like to do a bit more research to see if this is currently possible, and if not I would suggest you post this idea to our Moldflow Idea Station.  You can use this Moldflow Idea station if you have suggestions for the software or its functionality you would like the Moldflow Product Management to consider for future consideration.  Myself, and other Moldflow users can vote towards your idea also once posted here!

 

If my post answers your question, please click the "Accept as Solution" button. This helps everyone find answers more quickly!


Beth Mollica

 

 

 

 

Beth
-----------------
If my post answers your question, please click the "Accept as Solution" button. This helps everyone find answers more quickly!



Beth Mollica
Technical Support Specialist
Message 5 of 6
beth.mollica
in reply to: beth.mollica

The API command RunnerGen = Synergy.RunnerGenerator()  is the command specific to generating a runner system. As such, it needs to know where the injection locations to the cavity are.

 

If you want to know if an injection location exists than a script would need to be written explicitly for this.  There is no direct API call to determine this.

You would need to export the sdy file in ASCII format and extract and analyse the NDBC blocks to find injection locations.

 

With that being said, one of our scripting exports provided me with the attached text of a script to identify  injection nodes!

 

Please extract it to a file GetInjectionNodes.vbs

 

'@
'@ DESCRIPTION
'@ Get Injection Nodes
'@ 
'@
'@ SYNTAX
'@ GetInjectionNodes
'@
'@ PARAMETERS
'@ 
'@
'@ DEPENDENCIES/LIMITATIONS
'@  1/.  Minimal Error Checking
'@
'@  Author DRA 23/7/2009
'@ AS there is no direct Direct API calls to work with NDBC data
'@ We need to dump the study file in ascii format and read the NDBC data
'@@ 
Option Explicit
SetLocale("en-us")

Dim SynergyGetter, Synergy
On Error Resume Next
Set SynergyGetter = GetObject(CreateObject("WScript.Shell").ExpandEnvironmentSTetngs("%SAInstance%"))
On Error Goto 0
If (Not IsEmpty(SynergyGetter)) Then
    Set Synergy = SynergyGetter.GetSASynergy
Else
    Set Synergy = CreateObject("Synergy.Synergy")
End If
Dim FS
Set FS = CreateObject("Scripting.FileSystemObject")


Dim StudyDoc
Set StudyDoc = Synergy.StudyDoc

' read the mesh of the current study file
Dim InjectionData
Set InjectionData = New InjectionNodes
InjectionData.ReadInjectionNodes()

If InjectionData.Size() > 0 Then
    MsgBox "Injection Node(s) Found: " & InjectionData.Size(), vbInformation,WScript.ScriptName
    InjectionData.WriteData()
Else
    MsgBox "No Injection Nodes Found", vbInformation,WScript.ScriptName
End if
WScript.Quit(0)

' ---- InjectionNodes class
Class InjectionNodes
    Public mNodes()
    Private NumNode, mUdmFile
    
    Private Sub Class_Initialize
        NumNode = 0
        mUdmFile = GetTempFile(".udm")
    End Sub
    
    Public Sub ReadInjectionNodes
        ' Export the ascii udn
        Synergy.Project.ExportModel mUdmFile
        Dim FS, File, Line, I, ID
        Set FS = CreateObject("Scripting.FileSystemObject")
        Const ForReading = 1
        Set File = FS.OpenTextFile(mUdmFile, ForReading)
        Line = File.ReadLine
        While Not (File.AtEndOfStream)
            If InStr(Line, "NDBC{") > 0 Then
                If Left(Line,2) <> "//" Then  ' Skip comment lines
                    ProcessNDBC(Line)
                End if
            End If
            Line = File.ReadLine
        Wend
        File.Close
        FS.DeleteFile mUdmFile
    End Sub
    
    Private Function ProcessNDBC(Line)
        Dim Words, NodeID, NDBCType
        Words = SmartSplit(Line)
        NodeID = Words(8)
        NDBCType = Words(6)
        '40000 Injection location for thermoplastics processes
        '40002 Injection location for reactive processes
        '40003 Dispensing location
        If NDBCType = 40000 Or NDBCType = 40002 Or NDBCType = 40003 Then
            NumNode = NumNode + 1
            redim Preserve mNodes(NumNode)
            mNodes(NumNode-1) = NodeID
        End if
    End Function
    
    Public Function GetNode(I)
        GetNode = 0
        If I >= 0 And I <= NumNode-1 Then
            GetNode = mNodes(I)
        End If
    End Function
    
    Public Function Size()
        Size= NumNode
    End Function

    Public Sub WriteData()
        Dim II,lStr
        lStr = "Injection Node Numbers : "
        For II = 0 To NumNode-1
            lStr = lStr & mNodes(II) & "  "
        Next
        MsgBox lStr, vbInformation,WScript.ScriptName
    End Sub
    
End Class

' ---- Splits a line into words properly
Function SmartSplit(Str)
    Dim lStr
    lStr = Str
    LStr = Replace(lStr, "{", " ")
    lStr = Replace(lStr, "}", " ")
    SmartSplit = Split(Trim(lStr))
End Function

' ---- Gets temporary file location
Function GetTempFile(DesiredExtension)
    Dim FS, Temp, lName
    Const TemporaryFolder = 2
    Set FS = CreateObject("Scripting.FileSystemObject")
    Set Temp = FS.GetSpecialFolder(TemporaryFolder)
    lName = ""
    While lName = ""
        lName = Temp.Path + "\" + FS.GetTempName()
        lName = Replace(lName, ".tmp", DesiredExtension)
        If FS.FileExists(lName) Then
            lName = ""
        End If
    Wend
    GetTempFile = lName
End Function






WScript.Quit 

 

 

If my post answers your question, please click the "Accept as Solution" button. This helps everyone find answers more quickly!


Beth Mollica

 

Beth
-----------------
If my post answers your question, please click the "Accept as Solution" button. This helps everyone find answers more quickly!



Beth Mollica
Technical Support Specialist
Message 6 of 6
F.Porcher
in reply to: beth.mollica

Hello @beth.mollica,

 

I would like to ask, if any alternative solution was found to this problem. In my POV it seams extremely inefficient to export an *.udm file and parse thousands of lines in order to find the single line inside the "NDBC{}" block with the information about the coordinates of injection locations.

 

To my problem: I need to get the position of the all gates in multiple *.sdy models. However, since the *.udm files I'm working with are in the order of 500MB+, the method suggested here is impracticable. Currently, I'm trying to get the coordinates of every single gate like this:

 

' Set injection location propery
Const INJ_LOC_PROP = 40000

' Select all Injection Locations
Set PredicateInjLoc = PredicateManager.CreatePropTypePredicate(INJ_LOC_PROP)


Dim InjLoc_Str
Dim InjLocCoord()
Set EntList = MeshEditor.CreateEntityList()
Set InjLoc_Str = EntList.Entity(0)
EntList.SelectFromPredicate PredicateInjLoc
' MsgBox "Num. Inj. Loc " & CStr(EntList.Size)


If EntList.Size = 0 Then
	MsgBox "No Injection Location detected.",,"Error"	
Else
	' Create array to store injection location coordinates
	ReDim Preserve InjLocCoord( 2, CInt(EntList.Size)-1)	
	Dim Coord
	For i = 0 To EntList.Size-1
		Set Coord = StudyDoc.GetNodeCoord(EntList.Entity(i))
		InjLocCoord(0,i) = Coord.X
		InjLocCoord(1,i) = Coord.Y
		InjLocCoord(2,i) = Coord.Z		
		MsgBox "InjLoc " & CStr(EntList.Entity(i).ConvertToString()) &  " --- X " & CStr(InjLocCoord(0,i)) & " | Y "  & CStr(InjLocCoord(1,i)) & " | Z " & CStr(InjLocCoord(2,i))		
	Next
End If

 

This unfortunately results in nonsense values for X, Y and Z. Can you please tell me, why an EntList with the correct property ID of a injection location cannot deliver the correct coordinates?

 

P.S.: I see myself often limited to write scripts, since very little "getters" functions exist. As such, I'm unable to use most of the public member functions. As an example, I' m unable to use the ModeNDBCToXYZ() function, since there is no way to first get the location of a gate.

 

Regards,

F. Porcher

PhD Student

Technical University Berlin / BIT GmbH

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

Post to forums  

Autodesk Design & Make Report