ilogic trigger/ sketch symbol

ilogic trigger/ sketch symbol

DJFore
Advocate Advocate
2,934 Views
9 Replies
Message 1 of 10

ilogic trigger/ sketch symbol

DJFore
Advocate
Advocate

I have two questions the first is 

Is there anyway to create a button over the top of my company logo in my idw template that will trigger a dialog box?

I have the box and can set it to trigger and pop up with any of the supplied triggers but I do not know how to make location on my screen when clicked the trigger.

 

Second question is there a way with ilogic to turn on and off sketch symbols I have a drawing status box that my customer files checks but when the status of the drawing changes it needs to disappear I would like to automate into my ilogic rule

 

Any suggestions are welcome

Thanks

 

0 Likes
Accepted solutions (1)
2,935 Views
9 Replies
Replies (9)
Message 2 of 10

MjDeck
Autodesk
Autodesk

I can't think of a way to create something on the drawing that would act as a button to trigger a rule.  That's a good idea.

 

 Here's a rule that will turn a sketch symbol on and off.  I tried several ways, but the only thing that worked was to set the scale of the symbol very small, which turns it into a dot on the page.  I hope you can use this.

 

 Change the name "SampleSymbol" in Sub Main to match the name of your symbol.

SymbolOn is a True/False (Boolean) parameter in the drawing.  You can replace it with some other logic to decide if you want to make the symbol visible or not.

 

 To make it visible, this changes the scale to 1:1.  If your symbol needs to be at a different scale, you can edit this line, or make the scale a parameter to the function.

 

Sub Main
 SetSymbolVisible("SampleSymbol", SymbolOn)
End Sub

Sub SetSymbolVisible(symbolName As String, visible As Boolean)
  Dim drawingDoc As DrawingDocument = TryCast(ThisDoc.Document, DrawingDocument)
  If (drawingDoc Is Nothing) Then Return

  For Each sheetX As Sheet In drawingDoc.Sheets
    For Each sketched As SketchedSymbol In sheetX.SketchedSymbols
      If (sketched.Name = symbolName) Then
        If (visible) Then
 	  sketched.Scale = 1
        Else
	  sketched.Scale = 0.001
        End If
      End If
    Next
  Next
End Sub


 


Mike Deck
Software Developer
Autodesk, Inc.

Message 3 of 10

DJFore
Advocate
Advocate

I have attached the code I am using in ilogic how could I change this so that the dialog box is always open just resides off to the side of the drawing sheet (does not have a trigger)? Basically in this case I would just have a refresh button and not would have a OK or CANCEL. Also I thought of a good way if possible to change my sketch symbol how about it if I put it on a different layer that could be turned on and off? The part of my code that say's put a "X" in the custom iproperty should also turn on the symbol (maybe the layer I talked about). My final question I could use some help with is I have tried to tell it to put a X in the custom iproperty this works but it doesnt always turn off the X when a different status is selected. Any suggestions

 

Thanks for your help

I get these bugs worked out I will have some very happy designers

 

AddReference "Titleblock_vb1"
Sub Main ()
Dim dlg as New Titleblock_vb1.dialog1
dlg.vbworkorder=iProperties.Value("Custom", "WORK ORDER NO.")
dlg.vbjobno=iProperties.Value("Custom", "JOB NO.")
dlg.vbstatus=iProperties.Value("Custom", "AS-BUILT FOR RECORDS")
dlg.vbstatus=iProperties.Value("Custom", "PRELIMINARY SKETCH/INFORMATION ONLY")
dlg.vbstatus=iProperties.Value("Custom", "SUBMITTED FOR CUSTOMER APPROVAL")
dlg.vbstatus=iProperties.Value("Custom", "SUBMITTED FOR CUSTOMER CERTIFICATION")
dlg.vbstatus=iProperties.Value("Custom", "CERTIFIED FOR FABRICATION")
dlg.vbquoteno=iProperties.Value("Custom", "QUOTE NUMBER")
dlg.vbcreationdate=iProperties.Value("Custom", "CREATION DATE")
dlg.vbcustomerpo=iProperties.Value("Custom", "CUSTOMER PO")
dlg.vbcustomername=iProperties.Value("Custom", "CUSTOMER NAME")
dlg.vbdescription=iProperties.Value("Custom", "DESCRIPTION")
dlg.vbengineeringdate=iProperties.Value("Custom", "ENG APPROVAL DATE")
dlg.vbdrawnby=iProperties.Value("Custom", "DRAWN BY")
i=dlg.ShowDialog()

If (i=vbOK) Then
iProperties.Value("Custom", "WORK ORDER NO.")=dlg.vbworkorder
iProperties.Value("Custom", "JOB NO.")=dlg.vbjobno
iProperties.Value("Custom", "QUOTE NUMBER")=dlg.vbquoteno
iProperties.Value("Custom", "CREATION DATE")=dlg.vbcreationdate
iProperties.Value("Custom", "CUSTOMER PO")=dlg.vbcustomerpo
iProperties.Value("Custom", "CUSTOMER NAME")=dlg.vbcustomername
iProperties.Value("Custom", "DESCRIPTION")=dlg.vbdescription
iProperties.Value("Custom", "ENG APPROVAL DATE")=dlg.vbengineeringdate
iProperties.Value("Custom", "DRAWN BY")=dlg.vbdrawnby
'AS-BUILT FOR RECORDS STATUS'
If DLG.VBSTATUS= "AS-BUILT FOR RECORDS" Then 
iProperties.Value("Custom", "AS-BUILT FOR RECORDS")="X"
Else iProperties.Value("CUSTOM", "AS-BUILT FOR RECORDS")=""
'PRELIMINARY SKETCH/INFORMATION ONLY'
If DLG.VBSTATUS= "PRELIMINARY SKETCH/INFORMATION ONLY" Then 
iProperties.Value("Custom", "PRELIMINARY SKETCH/INFORMATION ONLY")="X"
Else iProperties.Value("Custom", "PRELIMINARY SKETCH/INFORMATION ONLY")=""
'SUBMITTED FOR CUSTOMER APPROVAL'
If DLG.VBSTATUS= "SUBMITTED FOR CUSTOMER APPROVAL" Then 
iProperties.Value("Custom", "SUBMITTED FOR CUSTOMER APPROVAL")="X"
Else iProperties.Value("Custom", "SUBMITTED FOR CUSTOMER APPROVAL")=""
'SUBMITTED FOR CUSTOMER CERTIFICATION'
If DLG.VBSTATUS= "SUBMITTED FOR CUSTOMER CERTIFICATION" Then 
iProperties.Value("Custom", "SUBMITTED FOR CUSTOMER CERTIFICATION")="X"
Else iProperties.Value("Custom", "SUBMITTED FOR CUSTOMER CERTIFICATION")=""
'CERTIFIED FOR FABRICATION'
If DLG.VBSTATUS= "CERTIFIED FOR FABRICATION" Then 
iProperties.Value("Custom", "CERTIFIED FOR FABRICATION")="X"
Else iProperties.Value("Custom", "CERTIFIED FOR FABRICATION")=""

End If
End If
End If
End If
End If
End If
End Sub

 

 

 

0 Likes
Message 4 of 10

MjDeck
Autodesk
Autodesk
Accepted solution

It is possible to make the dialog box stay open while you are doing other things in Inventor.  This requires some code changes to make the dialog work non-modally.  You would move the code to assign the iProperty values from your rule to the dialog.  Then use the function  dlg.Show  instead of   dlg.ShowDialog.   You should also add an event handler to the dialog so that the dialog will close if the document is closed.

 What version of Inventor are you using?

 

> how about it if I put it on a different layer that could be turned on and off?

I tried that (in Inventor 2011).  I could turn the text in a Sketched Symbol off, but not the lines (sketch geometry).  If you can get this to work manually (make your entire symbol invisible by turning off the layer) please let me know.  You can turn off a layer using a rule function such as:

ThisDoc.Document.StylesManager.Layers("Symbol (ANSI)").Visible = False

 

>  I have tried to tell it to put a X in the custom iproperty this works but it doesnt always turn off the X when a different status is selected.

You should be able to fix it by changing the last part of your rule to:

'AS-BUILT FOR RECORDS STATUS'
If DLG.VBSTATUS= "AS-BUILT FOR RECORDS" Then 
iProperties.Value("Custom", "AS-BUILT FOR RECORDS")="X"
Else 
iProperties.Value("CUSTOM", "AS-BUILT FOR RECORDS")=""
End If

'PRELIMINARY SKETCH/INFORMATION ONLY'
If DLG.VBSTATUS= "PRELIMINARY SKETCH/INFORMATION ONLY" Then 
iProperties.Value("Custom", "PRELIMINARY SKETCH/INFORMATION ONLY")="X"
Else 
iProperties.Value("Custom", "PRELIMINARY SKETCH/INFORMATION ONLY")=""
End If

'SUBMITTED FOR CUSTOMER APPROVAL'
If DLG.VBSTATUS= "SUBMITTED FOR CUSTOMER APPROVAL" Then 
iProperties.Value("Custom", "SUBMITTED FOR CUSTOMER APPROVAL")="X"
Else 
iProperties.Value("Custom", "SUBMITTED FOR CUSTOMER APPROVAL")=""
End If

'SUBMITTED FOR CUSTOMER CERTIFICATION'
If DLG.VBSTATUS= "SUBMITTED FOR CUSTOMER CERTIFICATION" Then 
iProperties.Value("Custom", "SUBMITTED FOR CUSTOMER CERTIFICATION")="X"
Else 
iProperties.Value("Custom", "SUBMITTED FOR CUSTOMER CERTIFICATION")=""
End If

'CERTIFIED FOR FABRICATION'
If DLG.VBSTATUS= "CERTIFIED FOR FABRICATION" Then 
iProperties.Value("Custom", "CERTIFIED FOR FABRICATION")="X"
Else 
iProperties.Value("Custom", "CERTIFIED FOR FABRICATION")=""
End If

 

 

Also, you can get rid of the End If at the end of the rule by changing the line:

If (i=vbOK) Then
to

If (i <> vbOK) Then Return


This will Return (exit from the rule) if i is not vbOK.

 

I would recommend keeping the code that I send to make the symbol invisible in a separate rule. (Unless we can make the method of turning the layer on and off work.  In that case the code would be simpler.)

 

If you use the code I send as a separate rule, you can trigger it by creating a True/False (Boolean) parameter named SymbolOn, and setting the value of this parameter to True or False in your dialog rule.  I'm not sure under what conditions you don't want to show the symbol.

 


Mike Deck
Software Developer
Autodesk, Inc.

0 Likes
Message 5 of 10

Mike.Wohletz
Collaborator
Collaborator

I have tried the option of turning the layer on and off and all it will do is turn off the leader to to symbol. Why not get the location of the label and name and store it in a custom property and then delete it from the drawing, when you need it back the same type of code can read the custom property and reinsert the symbol. 

 

 

0 Likes
Message 6 of 10

MjDeck
Autodesk
Autodesk

A sketched symbol can have prompted text that is different from what's in the definition.  It could be hard to save and restore everything that makes up the symbol.   I think my solution of scaling it down to a point is useable.  It makes for a simple rule that will work on any sketched symbol.

 

 But yes, it should be possible to save all the info, and then restore the symbol later.

 

 


Mike Deck
Software Developer
Autodesk, Inc.

0 Likes
Message 7 of 10

DJFore
Advocate
Advocate

MIKE DECK

THANKS! 

I AM USING INV 2011 PRO ON A 64 BIT SYSTEM

 

OK I THINK I FIGURED OUT THE LAYER PROBLEM YOU WERE HAVING I THINK IF YOU GO BACK INTO THE ACTUAL DEFINITION OF THE SYMBOL AND CHANGE ITS LAYER IT WORKS OTHERWISE IT FAILS.

SO HERE IS WHAT I DID FOR ANYONE ELSE OUT THERE

 

I CREATED A TRUE/FALSE PARAMETER I THEN ADDED THIS TO MY RULE

DSYMBOL=False
If iProperties.Value("Custom", "SUBMITTED FOR CUSTOMER APPROVAL")="X" Then
DSYMBOL= True
End If
iLogicVb.RunRule("SKETCH SYMBOL VIS")

 I THEN CREATED A NEW RULE AND CALLED "SKETCH SYMBOL VIS"  WITH THIS CODE IN IT

If DSYMBOL=True Then
ThisDoc.Document.StylesManager.Layers("DSYMBOL").Visible = True
Else
ThisDoc.Document.StylesManager.Layers("DSYMBOL").Visible = False
End If

 I THEN WENT CREATED A NEW LAYER CALLED "DSYMBOL"

WENT BACK INTO THE DEFINITION OF THE SYMBOL AND CHANGED ITS LAYER TO "DSYMBOL" RUN THE RULE AND IT WORKS! (MY SYMBOL JUST SHOWS UP ON A DRAWING FOR THE CUSTOMER TO USE FOR MARKUPS TO SEND BACK TO US THERE IS NO PROMPTED TEXT IN IT)

I GOT THE SCALE SYMBOL TO WORK AS WELL.

 

I DECIDED AT THIS TIME NOT TO MAKE THE DIALOG BOX VISIBLE AT ALL TIMES SO I SET UP A iTRIGGER FOR NOW.

 

 

 

 

0 Likes
Message 8 of 10

MjDeck
Autodesk
Autodesk

That makes sense.  I was thinking that the sketched symbol didn't have a layer until you put an instance of it in the drawing.  But the definition has layer information.

 

 Note that you don't need the statement:

iLogicVb.RunRule("SKETCH SYMBOL VIS")

in your rule.  When your main rule changes the parameter DSYMBOL, that second rule will run automationcally.


Mike Deck
Software Developer
Autodesk, Inc.

0 Likes
Message 9 of 10

DJFore
Advocate
Advocate

Ok thanks for the help!

0 Likes
Message 10 of 10

Ktelang
Collaborator
Collaborator

Thanks people that helped a lot

------------------------------------------------------------------------------
Config :: Intel (R) Xeon (R) CPU E31245 @ 3.30 GHz, 16.0 GB, 64bit win7
Inventor 2013 and Vault Basic 2013
-----------------------------------------------------------------------------
0 Likes