Mark parameters for Export

Mark parameters for Export

Jesper_S
Collaborator Collaborator
2,423 Views
9 Replies
Message 1 of 10

Mark parameters for Export

Jesper_S
Collaborator
Collaborator

Hi.

 

Is there a way using iLogic to mark renamed model parameters to be exported to custom iProperty?

I have a code that exports ALL parameters but i want to export just the parameters that Dont have "d" in the beginning of the name. (all model parameters as you all know are named d0, d1, d2 and so on).

 

//Jesper


//Jesper

Did you find this reply helpful ? If so please use the Accept as Solution or Kudos button below.
0 Likes
Accepted solutions (1)
2,424 Views
9 Replies
Replies (9)
Message 2 of 10

Ktomberlin
Advocate
Advocate
You would use: Parameter.Param("YOURVALUE").ExposedAsProperty = True
for a single value. For a list of them you could do it several ways, build an array, a For statement (For Each oParam In )
Message 3 of 10

MechMachineMan
Advisor
Advisor
If oParameter.Name Like "d*"
'Do not export
Else
'Export
End if

--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.

Justin K
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization


iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread

Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects

Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help

Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type
0 Likes
Message 4 of 10

Jesper_S
Collaborator
Collaborator

I have managed to export parameters with specific names and change the property format to what i want.

But i dont know how to get it to export all my named modelparameters.

Im very new to iLogic and how it works.

 

This is what i managed to put together.

SyntaxEditor Code Snippet

oParameter = Parameter.Param("Height")

If oParameter.Name Like "Height"
oParameter.ExposedAsProperty = True

End If

Dim oFormat As CustomPropertyFormat
oFormat=oParameter.CustomPropertyFormat

oFormat.Units="mm"
oFormat.ShowUnitsString=False
'set to show/not show the unit string (use True to show)
oFormat.ShowUnitsString=False
'set to show/not show the trailing zeros (use True to show)
oFormat.ShowTrailingZeros = False
'set to show/not show the leading zeros (use True to show)
oFormat.ShowLeadingZeros = False

//Jesper 


//Jesper

Did you find this reply helpful ? If so please use the Accept as Solution or Kudos button below.
0 Likes
Message 5 of 10

MechMachineMan
Advisor
Advisor
Accepted solution

 

Dim oCompDef As ComponentDefinition

Dim oParameter As Parameter


oCompDef = ThisApplication.ActiveDocument.ComponentDefinition

 

oModelP=oCompDef.Parameters.ModelParameters

 

For Each oParameter in oModelP
'If oParameter.Renamed=True

oParameter.ExposedAsProperty=True
'SVar.oList.Add(oParameter.Name)
'End If
Next


--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.

Justin K
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization


iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread

Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects

Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help

Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type
Message 6 of 10

Jesper_S
Collaborator
Collaborator

Thanks. That worked like a charm.

But now my code that changes the Custom Property Format doesnt work and i dont know whats wrong.

 

Getting :

Error in rule: Rule2, in document: Part4

Object reference not set to an instance of an object.

 

SyntaxEditor Code Snippet

Dim oCompDef As ComponentDefinition
Dim oParameter As Parameter

oCompDef = ThisApplication.ActiveDocument.ComponentDefinition
 
oModelP=oCompDef.Parameters.ModelParameters
 
For Each oParameter in oModelP
If oParameter.Renamed=True
oParameter.ExposedAsProperty=True
End If

Next

Dim oFormat As CustomPropertyFormat
oFormat=oParameter.CustomPropertyFormat

oFormat.Units="mm"

oFormat.ShowUnitsString=False

oFormat.ShowTrailingZeros = False

oFormat.ShowLeadingZeros = False

Whats wrong?

 

//Jesper 


//Jesper

Did you find this reply helpful ? If so please use the Accept as Solution or Kudos button below.
0 Likes
Message 7 of 10

MechMachineMan
Advisor
Advisor
First glance I can't see anything obvious. Put a message box in and move
it don't line by line, running code in between to do a manual debug.

--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.

Justin K
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization


iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread

Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects

Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help

Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type
0 Likes
Message 8 of 10

Jesper_S
Collaborator
Collaborator

SyntaxEditor Code Snippet

Dim oCompDef As ComponentDefinition
Dim oParameter As Parameter

oCompDef = ThisApplication.ActiveDocument.ComponentDefinition
 
oModelP=oCompDef.Parameters.ModelParameters
 
For Each oParameter in oModelP
If oParameter.Renamed=True
oParameter.ExposedAsProperty=True
End If

Next

Dim oFormat As CustomPropertyFormat
oFormat=oParameter.CustomPropertyFormat

'oFormat.PropertyType=Inventor.CustomPropertyTypeEnum.kTextPropertyType'oFormat.Precision=Inventor.CustomPropertyPrecisionEnum.kZeroDecimalPlacePrecision'oFormat.Units="mm"'set to show/not show the unit string (use True to show)'oFormat.ShowUnitsString=False'set to show/not show the trailing zeros (use True to show)'oFormat.ShowTrailingZeros = False'set to show/not show the leading zeros (use True to show)'oFormat.ShowLeadingZeros = False

This works but as soon as i add one more line, doesnt matter witch one of the "oFormat" lines i get the error.

 

Error in rule: Rule2, in document: Part4.ipt

Object reference not set to an instance of an object.

 


//Jesper

Did you find this reply helpful ? If so please use the Accept as Solution or Kudos button below.
0 Likes
Message 9 of 10

MechMachineMan
Advisor
Advisor
Move all of the format stuff into the if statement; you can only format
parameters that are exposed.

--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.

Justin K
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization


iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread

Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects

Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help

Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type
0 Likes
Message 10 of 10

Jesper_S
Collaborator
Collaborator

Many thanks. Worked.

 

SyntaxEditor Code Snippet

Dim oCompDef As ComponentDefinition
Dim oParameter As Parameter

oCompDef = ThisApplication.ActiveDocument.ComponentDefinition
 
oModelP=oCompDef.Parameters.ModelParameters
 
For Each oParameter in oModelP
If oParameter.Renamed=True
oParameter.ExposedAsProperty=True

Dim oFormat As CustomPropertyFormat
oFormat=oParameter.CustomPropertyFormat

oFormat.PropertyType=Inventor.CustomPropertyTypeEnum.kTextPropertyType
oFormat.Precision=Inventor.CustomPropertyPrecisionEnum.kZeroDecimalPlacePrecision
oFormat.Units="mm"

oFormat.ShowUnitsString=False

oFormat.ShowTrailingZeros = False

oFormat.ShowLeadingZeros = False

End If

Next


//Jesper

Did you find this reply helpful ? If so please use the Accept as Solution or Kudos button below.
0 Likes