this is my 1st attempt to write a logic rule and it is not working.
I am trying to fill in my title block customer with a rule.
The custom property is customer
CUSTOM IPROPERTY
PARAMETERS
ERROR
CODE
Dim propertyName1 As String = "Customer" oCustomPropertset = ThisDoc.Document.PropertySets.Item("Inventor User Defined Properties") Try 'set proprty value Catch oCustomPropertySet.Item("Customer customer") End Try
Your problem is on line 6. I would assume it is because you are calling sring oCustomPropertyset, but you actually defined it without the y as oCustomPropertset
Have you also tried this?
iProperties.Value("Custom", "PropertyName")
Also, you're not actually doing anything, just giving an instruction if it catches an error.
What do you actually need to do?
Create a custom iproperty?
Ask the user for a value of customer? Where does this value come from?
Do you actually want it in the titleblock or in a normal text block?
I want to fill out the customer property field I created
it uses the customer property and a vararible that is multi value. Here is code that I copied and a link to the youtube video. Go to minute 4:10
'change Custom iProperty Name to desired Custom iProperty Name Dim propertyName1 As String = "CUSTOMER Name" 'define custom property collection oCustomPropertySet = ThisDoc.Document.PropertySets.Item("Inventor User Defined Properties") Try 'set property value oProp = oCustomPropertySet.Item(propertyName1) Catch ' Assume error means not found so create it oCustomPropertySet.Add("", propertyName1) End Try 'set custom property value; Change Custom iProperty Name to desired Custom iProperty Name; 'change UniqueFxName to the name of your User Defined Parameter iProperties.Value("Custom", "CUSTOMER Name") = CUSTOMER 'processes update when rule is run so save doesn't have to occur to see change iLogicVb.UpdateWhenDone = True
Hi @kadscad
Is the multivalue parameter within the drawing only or are you bringing it in from the model via a view reference
If your just working with drawing parameter to set a drawing iproperty then the the two following methods will work for you. The ilogic API method number 1 is the easiest and it will create the parameter and set the value in that one small line of code. It actually is a function which utilizes the Invetor API method shown in method 2. So if your a beginner I would suggest sticking with method 1 for this operation.
Method 1: Ilogic API
'set custom property to parameter value.
iProperties.Value("Custom", "CustomerName") = CUSTOMER
iLogicVb.UpdateWhenDone = True
Method 2: Inventor API
Dim propertyName1 As String = "CustomerName" 'define custom property collection
Dim customPropSet As PropertySet = ThisDoc.Document.PropertySets.Item("Inventor User Defined Properties")
Dim prop As Inventor.Property
Try
'set property value.
prop = customPropSet.Item(propertyName1)
Catch ' Assume error means not found so create it prop =
prop = customPropSet.Add("", propertyName1)
End Try
'set custom property to parameter value.
prop.Value = CUSTOMER
iLogicVb.UpdateWhenDone = True
Can you share screenshots of both parameter and iproperty? Is there an error message? Is your rule internal/external? Have you placed the drawing custom iproperty in the title block? Can you share screenshot of its field and where you selected it from the drop down?
Hi! I think I know where the problem is. The <CUSTOMERNAME> iProperty is a bit overloaded here. The one referenced by the Titleblock needs to come from the model source iam/ipt file. Instead of that one, it should be the <CUSTOMERNAME> from current drawing (source).
Many thanks!
This is what I am trying to duplicate. start at minute 4
my custom iproperties
parameters
title block
rule
Dim propertyName1 As String = "CustomerNames" 'define custom property collection Dim customPropSet As PropertySet = ThisDoc.Document.PropertySets.Item("Inventor User Defined Properties") Dim prop As Inventor.Property Try 'set property value. prop = customPropSet.Item(propertyName1) Catch ' Assume error means not found so create it prop = prop = customPropSet.Add("", propertyName1) End Try 'set custom property to parameter value. prop.Value = CUSTOMER iLogicVb.UpdateWhenDone = True
It looks like your not using the custom properties from the drawing but rather from the model. Go back to the text editor and look for drawing iproperties. You must have the iproperty created to be able to map the iproperty formatted text field. Disregard your ilogic for a second and get a custom drawing iprop to appear first manually. Then you can use ilogic to fill this iprop from the parameter.
So I went back into an ipt file and created the custom IProperty.
I inserted that ipt file and the title updates in the dwg.
In order to change the iproperty value, I have to go back into the ipt file, change the value, return to the dwg, and update it.
The ipt or iam file shouldn't inhibit a function I want to be driven in the dwg file.
Shouldn't I be able to drive this with a form inside the dwg file, similar to the prompt menu?
The customer field will actually be changed to the Project name.
I want to be able to have a drop-down menu for the project name, address, and job (which is a segment of the overall project) and fetch the page name for the sheet name.
From your description your using the model custom iproperty and not the from the drawing.
When the iproperty is created in the drawing you should see Custom Properties-Drawing in the drop down in order to add the iproperty.
It doesn't look exactly like the one in the link. The layout is different
For some reason, it is now working. I can also go into my parameters and use the multivalue drop-down.
Can't find what you're looking for? Ask the community or share your knowledge.