Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem with Frame and Title block macro for counting parameters in CATIA drafting 1

Status
Not open for further replies.

milasko

Mechanical
Nov 24, 2016
5
RS
Hi.

I am trying to build a new macro for Frame and Title block for my company. I have been learning CATIA Scripting for 2 weeks. I want to insert some Parameters which will be later used for populating Title block. After I had defined desired parameters I encountered a problem with duplication of parameters for each new sheet. So I defined "If-Then" statement to prevent parameters` creation if parameters already exist, but it didn`t work. Parameters aren`t being created. If I delete If-Then statement parameters will be created. Does anyone have a solution for this kind of problem?
Here is part of my code:

Dim objParams As Parameters
Dim objParam As Parameter
Set objParams = CATIA.ActiveDocument.Parameters
If objParams.Count = 0 Then
Set objParam = DrwDocument.Parameters.CreateString ("Uradio", "M.Milasinovic")
Set objParam = DrwDocument.Parameters.CreateString ("Odobrio", "N.Jankovic")
Set objParam = DrwDocument.Parameters.CreateString ("Br.projekta", "V-20")
Set objParam = DrwDocument.Parameters.CreateString ("ID.projekta", "A2V0000")
Set objParam = DrwDocument.Parameters.CreateString ("Model", "RRX")
End If

Regards,

Marko!
 
Replies continue below

Recommended for you

try to look into DrawingDocument.Parameters.RootParameterSet.AllParameters

Eric N.
indocti discant et ament meminisse periti
 
Thanks for answer. It`s working now.

Regards,

Marko!
 
Hi,

I stucked again. This time I have problem with attribute linking string Parameter with Text. I tried with InsertVariable command, but with no luck.

Here is my code:
Dim objParams As Parameters
Dim objParam As Parameter
Set objParams = CATIA.ActiveDocument.Parameters
If DrwDocument.Parameters.RootParameterSet.AllParameters.Count = 0 Then
Set objParam = DrwDocument.Parameters.CreateString ("Uradio", "M.Milasinovic")
Set objParam = DrwDocument.Parameters.CreateString ("Odobrio", "N.Jankovic")
Set objParam = DrwDocument.Parameters.CreateString ("Br.projekta", "V-20/2395")
Set objParam = DrwDocument.Parameters.CreateString ("ID.projekta", "A2V0000")
Set objParam = DrwDocument.Parameters.CreateString ("Model", "RRX")
End If

Set Text = DrwTexts.Add("Text_05", OH-185+15+20+1, OV+55)
Text.InsertVariable 0,0,Uradio

Thanks in advantage!
 
I resolved the problem by replasing last row with Text.InsertVariable 1, 3, DrwDocument.Parameters.Item("Uradio")
 
thanks for sharing the answer

Eric N.
indocti discant et ament meminisse periti
 
I just don't understand why don't you create user parameters in part or assy?
 
Well,

I did it because I wanted to save time for making same parameters for every project. In this way, the parameters can be used by the other colleagues and a script can be easily adjusted to have their names.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top