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!

Create the (Product+3DShape) couple Catia V6 1

Status
Not open for further replies.

KABEL

Automotive
Dec 10, 2018
29
MA
Hello everyone,
I've been spending days trying to figure out how to create a Product then place in a 3DShape inside this product created, I tried this code below:

Code:
Sub CATMain ()
[COLOR=#73D216]'-----create a product[/color] 

dim oNewService As PLMNewService2
set oNewService = CATIA.GetSessionService("PLMNewService2")
Dim oEditor As Editor 
oNewService.PLMCreate "VPMReference",oEditor

[COLOR=#73D216]'------for the next line i want to add a 3DShape to this product I've created[/color] 

oNewService.PLMCreate "3DShape",oEditor  [COLOR=#EF2929]'the 3dshape is created alone in a new window[/color]  
End Sub

as you can see in the code above, I have problem adding a 3DShape to the product ,

for more details , in V5 I can do that using the code below

Code:
Sub CATMain ()
dim documents1 As Documents 
set documents1=CATIA.Documents
dim productdocument1 As ProductDocument
set productdocument1=documents1.Add("Product")
dim products1 As Products
set products1=productdocument1.Products
dim product2 as product
set product2=products1.AddNewComponent("Part","")
End Sub

Any hint is really appreciated!

Regards
 
Replies continue below

Recommended for you

Can someone please help me out? [bowleft]
 
LWolf
thank you, I really appreciate your feedback , I've already checked this topic, its not what I'm looking for,

ferdo
thank you for reply , could you please copy the thread presented in your COE Link, cuz I'm trying to access to the link but the login page keeps me of the thread, I registered but still not receiving the mail containing my password,

login_htz8mh.png


Thanks for your attention. I’m looking forward to your reply.

________
regards
 
@KABEL, please send email to coe@coe.org if you have a problem, they should be able to fix it.

Eric N.
indocti discant et ament meminisse periti
 
ferdo
Many thanks, you're too kind,I really appreciate your support,
First I'm using catia v6R2013, What I want to achieve is to create PDD (product) then insert (create inside) a 3DD (3DShape);
I found this way :
[ul]
[li]Retrieve the VPMReference object from the PDD after it has been created(root object of the editor : MyEditor3DShape1)[/li]
[li]Retrieve the 3DShape object after it has been created (root object of the editor : MyEditor3DShape2)[/li]
[li] Instantiate 3DD behind PDD (VPMRefPDD.Instances.Add 3DShape, VPMNewInst)[/li]
[li]Close MyEditor3DShape2[/li]
[/ul]

here is my code :

Code:
Sub CATMain()

Dim My3DPartService As PLMNewService2
Set My3DPartService = CATIA.GetSessionService("PLMNewService2")
Dim MyEditor3DShape As Editor

My3DPartService.SetAttributeValue "V_CustoDiscipline", "PDD"
My3DPartService.PLMCreate "VPMReference", MyEditor3DShape               [COLOR=#4E9A06]'the product now is created[/color] 

'   -   Retrieves the Product Service
    Dim MyProductService As PLMProductService
    Set MyProductService = CATIA.GetSessionService("PLMProductService")

'   -   Retrieves the Root Occurrence
    Dim MyVPMRootOcc As VPMRootOccurrence
    Set MyVPMRootOcc = MyProductService.RootOccurrence

'get vpmreference
Dim oVPMRefOnRoot As VPMReference
Set oVPMRefOnRoot = MyVPMRootOcc.ReferenceRootOccurrenceOf

' Create 3DPart
Dim oEditor3DShape As Editor
My3DPartService.SetAttributeValue "V_CustoDiscipline", "3DD"
My3DPartService.PLMCreate "3DShape", oEditor3DShape                 [COLOR=#4E9A06]'the 3DShape is now created in a new window[/color] 

' Get Part from Editor
Dim oPart3D As Part
Set oPart3D = oEditor3DShape.ActiveObject

' Get VPMRepReference
Dim oVPMRepRef As VPMRepReference
Set oVPMRepRef = oPart3D.Parent

' Get VPMReference
Dim oVPMRef As VPMReference
Set oVPMRef = oVPMRepRef.Father          [COLOR=#EF2929]'<=== I got an error for this line  " the [b]Father[/b] method of the object [b]VPMRepReference[/b] failed[/color] 

'' Get window of initial 3dShape creation
Dim oMy3DPartWindowToClose As Window
Set oMy3DPartWindowToClose = CATIA.ActiveWindow

' Insert 3DPart Under root product
Dim oVPMInst As VPMInstance
oVPMRefOnRoot.Instances.Add oPart3D, oVPMInst   [COLOR=#EF2929]'<==== also for this line, type mismatch , the oPart3D need to be a VPMReference object ,[/color] 

' Close 3DPart window
oMy3DPartWindowToClose.Close

End Sub

please help me out, I'm really stuck
thanks again,
------------------------------------------------------------------------------
itsmyjob
thank you, I really appreciate your feedback, I'll try to get in touch with their support , thank you.
Regards


 
You go up from the VPMRepRef to the VPMRef by passing by the VPMRepInstance

then maybe replace the oPart3D in the final line with the oVPMRef

Eric N.
indocti discant et ament meminisse periti
 
itsmyjob
could you please show me (the code) how to do that ?
thanks in advance
regards;
 
@kabel...

Sorry I was wrong:

Code:
Dim oVPMRef As VPMReference
Set oVPMRef = oVPMRepRef.Father

is good, it's just that the 3DShape editor is on a shape with no Part or product above, that's why its failing.

I try

Code:
My3DPartService.PLMCreate "3DPart", oEditor3DShape

but I receive licensing error, I know that with proper license it worked because I use this and just copy/paste the part from the new editor to the product where I wanted the instance...

I guess you should talk to your VAR or DS about this...

Can you make a Product template then use it to create new part/shape in your product so you bypass the lic. limitation?

Eric N.
indocti discant et ament meminisse periti
 
itsmyjob
Thank you too much, I understand now,
in my case I don't receive any licencing error, the only thing I can't do is to create a 3DPart, I receive an error on the checking of the discipline client attribute SetAttributeValue "V_CustoDiscipline","PDD", I'm getting in touch with the DS about this issue,
thank you again, I really appreciate your help,
------------
Regards
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top