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!

Search / Change 2d component o Text feature name

Status
Not open for further replies.

LuKeUmbo

Automotive
Nov 21, 2018
15
IT
Hi to all,
I have a macro script to compile my customer title block on the A3 format but I can't fill the date because the text has the same feature name of the 2D component (see attached picture).
The macro script find 2 occurrence with the same name and then stop there.
So I've thought to add to the script a command to change the feature name of the 2D component, fill the date and then give back to the 2D component his original name.

As workaround I thought to add to the main script to search only text's with "A3" as feature name, or to change the "A3" text feature name but I don't find anything to make this kind of operation.


Obviously I can do this manually but my goal is to automate the operation with one click. This must be colleague friendly ^__^

screenshot.1607083235_xsmpyf.jpg



Thank you in advance
 
Replies continue below

Recommended for you

Hi,
happy new year!

Is there someone that can help me in my question?

Thank you
 
Hi,
here is the code:

Code:
Tday = Date
Dfutura = Format(Tday, "dd/mm/yy")
DCheckedate = Format(Tday, "dd/mm/yyyy")
Ggnext = InputBox("Digitare data presunto rilascio CID", "Data presunta rilascio CID", Dfutura)
GgCheckeBy = InputBox("Digitare data CheckedBy", "Data presunta CheckdBy", DCheckedate)

Dim drawingDocument1 As Document
Set drawingDocument1 = CATIA.ActiveDocument

Dim Selection1 As Selection
Set Selection1 = drawingDocument1.Selection

Selection1.Search "Name=A3,all"
Set DataDis = Selection1
DataDis.Item(1).Value.Text = Ggnext

Dim Selection2 As Selection
Set Selection2 = drawingDocument1.Selection

Selection2.Search "Name=TechnicalReferenceDate,all"
Set DrawnBy = Selection2
DrawnBy.Item(1).Value.Text = GgCheckeBy

As you can see (image on my first post) on my code Selection1 search for A3.
But A3 is the name of Ditto and the text I want to change.
So the script halt because can't change 2 name (I think).

Maybe is possible to search by feature name AND only texts or, as a workaround, seach Ditto feature name, rename it, search for A3, renaming the text and then search again the Ditto and revert his feature name to the original.

Ps.: my apologize if I'm not clear on explanation. I'm not a programmer, this is a cut/paste of codes finded on the web....and my knowledge of english is a little poor ^__^

Thank you in advance
 
hello Luke;
it does not matter how many items your selection discovers, you are only adressing the first one anyways. (selection1.item(1))
you could try and see if the item you've selected is of type drawingtext:
If TypeName(DataDis.item(2).Value) = "DrawingText" Then DataDis.item(2).Value.Text = Ggnext

for the case of having more than one item found, make a loop that goes thru all the selections...

Selection1.Search "Name=A3,all"
Set DataDis = Selection1
Dim i As Integer
For i = 1 To DataDis.Count
If TypeName(DataDis.item(i).Value) = "DrawingText" Then DataDis.item(i).Value.Text = Ggnext​
Next

regards,
LWolf
 
@Lwolf it works like a charm ^__^
Thank you for your interesting and for sharing your knowledge with me to solve my issue

Bye
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top