Welcome to the COE Discussion Forum! 

 

To participate in the discussion forum, you must be logged in to the website.  If you forget your login information, please contact COE Headquarters at coe@coe.org or (800) 263-2255.

If you are new to the COE Discussion Forum and would like to participate, please register.

 

The COE 2008 Fall Industry Workshops

Experience two days of industry-focused education and hands-on training on the Dassault PLM solutions suite of products.  All education featured at the workshop is developed by and for users of CATIA®, ENOVIA®, DELMIA® and SIMULIA®.
 

Automotive
Oct. 15-16
Troy, Michigan

Aerospace & Defense
Oct. 27-28
Wichita, Kansas


Forum Highlight: CATIA V6

 

Get Answers to Your V6 Questions
Dassault Systèmes answers user questions about CATIA V6.  Discuss these answers and propose new questions with end users from around the world in the CATIA V6 Forum.

COE DISCUSSION FORUM
Subject: Publication troubles...

You are not authorized to post a reply.   
Author Messages
MBERRY

07 Aug 2008 02:28 PM
I am trying to create publications on geometry in a part with VB. So, I have many instances of a particular UDF (User Defined Feature) and I want to publish the same output from each UDF instance. Of course, each UDF has the exact same output names too.  The problem is how to build a reference for each element to be published when the element names are the same.
 
...At first, I used the CreateReferenceFromObject method on the part to make a reference and pass that it to the Publications.SetDirect method. Yeah, it didn't like that. So then I figured maybe you have to create the reference from the product object, so I tried using the CreateReferenceFromName method on the product object (This is the only way to make a reference from the product). The problem here is what to pass for the iLabel argument?
 
If you use the record mechanism to get the correct syntax, it only seems to care about the part and the element name when it develops the label. For example, if I have 3 UDF's in Geometrical Set.1 in Part1 and I want to publish the output called Line_X from each of the UDF instances, it will record the exact same label when developing all 3 references,

Set reference1 = product1.CreateReferenceFromName("PART1 /!Line_X"

Set publication1 = publications1.Add("AP1"

publications1.SetDirect "AP1", reference1
 
I tried going in and manipulating the label many times to do something like this,
 
Set reference1 = product1.CreateReferenceFromName("PART1 /Geometrical Set.1/UDF.1/!Line_X"
 
Nothing seems to work. It ignores you and always locates the part and finds the first element in the part with that name. 

Anybody know how to publish multiple elements having the same name?

-Mike

SKWOK

07 Aug 2008 08:41 PM
Mike, this may sound really inefficient, but when I want to pass actual objects around I tend to dig through the items one at a time and read the names into a giant variable. So I'll read in something like

Set HybridBodies As Part1.HybridBodies
For n=1 To HybridBodies.Count
MyHybridBodies(n) = HybridBodies.Item(n).Name
Next

Then I loop through my variables and call commands by the item number:

While i If MyHybridBodies(i) = "Line_X" Then
publications1.SetDirect "AP1", HybridBodies.Item(i)
End If
Wend

Naturally to account for the fact that you have more than one with the correct name you'll have to set and clear a flag that says indicates that you've already used a certain item.

Oh, and I just wrote that freehand, it now occurs to me that HybridBodies refers to the Geometric sets themselves, you probably want HybridBody1 = Hybridbodies.Item(1) and use HybridBody1.Item(n). But you get the picture...

Hopefully someone else has a more efficient elegant solution, but I tend to do it that way...

Steven Kwok
PLM Solutions Consultant
CATIA V5 Instructor
TechniGraphics Inc.
CATIA V5 R16/17/18
CATVBA
VB 6.0
Visual Basic .NET 2003/2005
MBERRY

08 Aug 2008 07:31 AM
Hi Steven,

The key thing here is that you can't pass the "actual" object to the Publications.SetDirect method. You have to first create a reference to the object and pass that. So the problem is how to create a reference to the item you want.

I cannot get the Product.CreateReferenceFromName() method to create a reference to the geometry I want, because it always grabs the first item in the part that has that name. I am sure it is just some trick with how you structure the name string that is passed to this method. I tried many variations on this name with no luck...

Record yourself making 2 publications in a part to 2 elements having the same name (doesn't matter where they are located in the tree) and you will see what I mean.

Mike
CLIFFJOHNSON


08 Aug 2008 09:39 AM
I ran into this before.

I was able to rename each object before publishing.
MBERRY

08 Aug 2008 01:52 PM
You are the man Cliff!

After I read your post, it seemed like an almost obvious solution.

Anyway, it worked like a charm - Thanks.

Mike
Bobby Ess

22 Sep 2008 05:25 AM

Mike and Cliff..

Funnily enough I am having the exact same issue.. CreateReferenceFromName fails each time..  it seems to almost be related to the part I have loaded though.

I was pleased to see that Mike resolved it, but I couldn't really understand why Cliff's suggestion worked? Was the suggestion that you just rename the feature to be Published just prior to actually Publishing it? Was that what was meant?

I'm not sure that is the issue in my case - in my script, prior to the Publication I just created the geometric feature that is going to be Published.. I gave it a name at the same time that I think is 99% unique in the part..

Any ideas? Thanks..

MBERRY

29 Sep 2008 07:04 AM
Bobby,

Sorry for delay, i was on vacation...anyway the problem here (at least the prob I had) is that when you use the CreateReferenceFromName method, it will find the first object in that part having that name (there is no way to specify the path, ie geo set, etc.) so if you have more than one object with the same name and you want to publish the 2nd or 3rd one it doesn't work. So Cliff's work around was to rename the object to something you know is unique, then create the reference to it then rename it back to what it was before. 99% unique is no good, unless you are 100% you will have to do what I described.

Mike
Bobby Ess

02 Oct 2008 01:11 AM

Thanks for the response Mike, it makes sense now..  I'm not sure it will work in my scenario, in which I only just created the element and gave it a name, which I'm pretty sure is already unique..  CreateReferenceFromName fails for me so far only on one or two parts, and they happen to be R11 parts..   even if you New From those parts, and remove all geometry, etc, to effectively leave an empty part, perform  CATDUA also, it will still fail on CreateReferenceFromName.. 

Ah well, I'll keep investigating.

Thanks again.

You are not authorized to post a reply.
Forums > COE Forums > CATIA V5 Programming > Publication troubles...



ActiveForums 3.6

    

401 North Michigan Avenue, Chicago, IL 60611-4267 | (312) 321-5153 | (800) COE-CALL (U.S.)