Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

USE CUSTOM IPROPERTIES TO FILL IN TITLE BLOCK

13 REPLIES 13
Reply
Message 1 of 14
kadscad
482 Views, 13 Replies

USE CUSTOM IPROPERTIES TO FILL IN TITLE BLOCK

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

 

kadscad_0-1711379005432.png

CUSTOM IPROPERTY

kadscad_4-1711379869546.png

 

 

 

PARAMETERS 

kadscad_2-1711379566253.png

 

ERROR

kadscad_3-1711379668301.png

 

 

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	

 

Kirk
Inventor 2023
13 REPLIES 13
Message 2 of 14
James_Willo
in reply to: kadscad

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")


James W
Inventor UX Designer
Message 3 of 14
James_Willo
in reply to: kadscad

Also, you're not actually doing anything, just giving an instruction if it catches an error. 

 

 



James W
Inventor UX Designer
Message 4 of 14
James_Willo
in reply to: kadscad

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?

 

 



James W
Inventor UX Designer
Message 5 of 14
kadscad
in reply to: kadscad

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

 

 

Kirk
Inventor 2023
Message 6 of 14
A.Acheson
in reply to: kadscad

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

 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
Message 7 of 14
kadscad
in reply to: kadscad

still no luck

I tried both

Kirk
Inventor 2023
Message 8 of 14
A.Acheson
in reply to: kadscad

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?

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
Message 9 of 14
johnsonshiue
in reply to: kadscad

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!



Johnson Shiue (johnson.shiue@autodesk.com)
Software Test Engineer
Message 10 of 14
kadscad
in reply to: johnsonshiue

This is what I am trying to duplicate. start at minute 4

https://www.youtube.com/watch?v=EtJV28qd9Ss&list=PL9ObidlzVlRE9-vtC5pz0MbXccn0mhqXY&index=184&t=311s...

 

my custom iproperties

 

kadscad_0-1711497908378.png

parameters

kadscad_1-1711498021775.png

title block

 

kadscad_2-1711498112976.png

 

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

 

 

 

 

 

 

 

 

 

 

 

Kirk
Inventor 2023
Message 11 of 14
A.Acheson
in reply to: kadscad

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. 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
Message 12 of 14
kadscad
in reply to: kadscad

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.

 

Kirk
Inventor 2023
Message 13 of 14
A.Acheson
in reply to: kadscad

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.

See post here. If you cant see it pleaplease screenshot your drop down lost and ensure the iproperty...

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
Message 14 of 14
kadscad
in reply to: kadscad

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.

 

kadscad_0-1711579445859.png

 

Kirk
Inventor 2023

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

Post to forums  

Technology Administrators


Autodesk Design & Make Report