CATIA V6 二次开发—获取非激活产品/零件(QA)

简介: CATIA V6 二次开发—获取非激活产品/零件(QA)

Q(cao bingyong):


Hi, I am new in V6 COM development, and recently encountered a problem of getting the GeoSet from another part (not in active) which is in another product. I can use the following code to get the root product , but have no idea to find the child product of the root one by name, not to mention, to find the part inside. So, can anyone help? Thanks a lot!

pLMProductService.EditedContent.Item(1)

A(Mahefa Ralijaona):

Hello,
There are I think several ways to do this. Here is one of them: not necessarily the fastest or the simplest, but it's one way. Hope it helps.
Sub CATMain()
    ' Getting active editor (the current tab)
    Dim oActiveEditor As Editor
    Set oActiveEditor = CATIA.ActiveEditor
    ' Getting the root occurrence of the editor
    Dim vpmRootOcc As VPMRootOccurrence
    Set vpmRootOcc = oActiveEditor.GetService("PLMProductService").RootOccurrence
    ' Getting all its children
    Dim vpmRootChildrenOcc As VPMOccurrences
    Set vpmRootChildrenOcc = vpmRootOcc.Occurrences
    ' Getting the first one (28629.1 in your case)
    Dim vpmRootChild1Occ As VPMOccurrence
    Set vpmRootChild1Occ = vpmRootChildrenOcc.Item(1)
    ' Getting the first part inside your 28629.1 (instance 28628.2 of the 3DPart in your case)
    Dim vpmPart1Occ As VPMOccurrence
    Set vpmPart1Occ = vpmRootChild1Occ.Occurrences.Item(1)
    ' Getting the part instance, then the reference
    Dim vpminstPart As VPMInstance
    Set vpminstPart = vpmPart1Occ.InstanceOccurrenceOf
    Dim vpmrefPart As VPMReference
    Set vpmrefPart = vpminstPart.ReferenceInstanceOf
    ' Getting the 3DShape instance, then the 3DShape reference
    Dim vpmrepinstPart As VPMRepInstance
    Set vpmrepinstPart = vpmrefPart.RepInstances.Item(1)
    Dim vpmreprefPart As VPMRepReference
    Set vpmreprefPart = vpmrepinstPart.ReferenceInstanceOf
    ' Getting the part item from the part(i.e. so far the 3DShape is a PLM object, we need to get to the object allowing to access the internal features of that PLM object)
    Dim oPart As Part
    Set oPart = vpmreprefPart.GetItem("Part")
    ' Getting the geometrical sets
    Dim oHybridBodies As HybridBodies
    Set oHybridBodies = oPart.HybridBodies
    ' Getting the first one
    Dim oGeoSet1 As HybridBody
    Set oGeoSet1 = oHybridBodies.Item(1)
    ' Check
    MsgBox oGeoSet1.Name
End Sub

Q(cao bingyong):


It works! Thanks very much. In addition, my objective is to find the shape in the unactive Part, and use it in my active Part to go on my geo operation. When I use it in a direct way, it goes wrong, and is it necessary to copy and paste(as result) the shape to my active Part before I do the following geo operation? Hope for your reply. Thanks again for your help!

 // CurrentPart is the active Part
 HybridShapeFactory hsf = (HybridShapeFactory)CurrentPart.HybridShapeFactory;
 // line1 and line2 are shapes I got from the unactive Part
 var point1 = hsf.AddNewPointOnCurveFromPercent((Reference)line1, 0.5,false);
 var point2 = hsf.AddNewPointOnCurveFromPercent((Reference)line2, 0.5, false);
 var line3 = hsf.AddNewLinePtPt((Reference)point1, (Reference)point2);
 CurrentPart.HybridBodies.Item(1).AppendHybridShape(line3);
 CurrentPart.Update();

A(Mahefa Ralijaona):

Yes, might be necessary to do so (copy paste “As Result” or “With Link”, or …). I’m not 100% sure but I think you won’t be able to do anything in your active part by directly pointing to an element that is outside. Unless maybe check your Preferences? In your Preferences, make sure that when you are using an object that is outside, you keep a link to the selected object (see picture attached).


20210118093126666.png

Q(cao bingyong):

Thanks for your reply! I have checked my preferences, and the button in the picture has already been selected. Maybe it is essential to copy and paste the object outside when using the automation.


Thank you again, and good luck to you!


目录
打赏
0
0
0
0
6
分享
相关文章
2025年五款电梯维保管理系统评测
本文对市面上主流的电梯巡检系统优缺点进行分析,方便大家可根据自身规模和技术能力选择合适的巡检系统。
选择文档管理软件前,必须了解的五个关键点 
在信息化时代,文档管理软件成为工作中的必备工具,尤其在团队协作和项目管理中。本文从功能、易用性、协作性和安全性等方面,对比了几款主流文档管理软件,包括板栗看板、Google Docs、Microsoft OneNote、Evernote和Notion,旨在帮助用户做出合理选择。
中型设计团队的项目可视化管理,啥办公软件才够给力?
本文介绍3款适用于设计行业的团队可视化办公管理软件:板栗看板、Trello和Asana。板栗看板以其简洁直观的看板展示、强大的任务管理和便捷的团队协作机制著称,特别适合国内设计团队使用。Trello通过灵活的看板体系和丰富的插件支持,提供全球化社区资源和跨行业应用的灵活性。Asana则以多视图项目展示、精细的任务关联与分组及实时数据分析报告,为设计团队提供深度任务管理和数据驱动的决策支持。这三款软件各具特色,旨在提升设计团队的协作效率和项目管理能力。
56 4
游乐场管理系统|基于Java开发实现游乐场综合管理系统平台
游乐场管理系统|基于Java开发实现游乐场综合管理系统平台
145 0
C#第三方实验室LIMS管理系统(成品源码)
LIMS系统的功能根据实验室的规模和任务而有所不同,其系统主要功能包括:系统维护、基础数据编码管理,样品管理、数据管理、报告管理、报表打印、实验材料管理、设备管理等。它可以取代传统的手工管理模式而给检测实验室带来巨大的变化,提高检测实验室的整体业务能力和工作效率,由此全面提高检测实验室的管理水平
180 0
转:在文档管理软件中匈牙利算法应该如何应用
匈牙利算法在文档管理软件中的应用非常广泛。匈牙利算法可以用来解决二分图最大匹配问题,而在文档管理软件中,可以将计算机和网络设备之间的连接关系视为一个二分图,计算机和网络设备分别作为二分图的两个部分。
79 1
水果编曲软件FL Studio 21版本强化来袭
水果编曲FL Studio 21强化来袭!全新功能介绍AI编曲时代。目前FL Studio 水果编曲已提供超过20款自研插件,还支持VST和AU插件,但这些我们觉得还远远不够!FL STUDIO 21 新版本将迎来主题更换新功能,水果用户们能随意更换自己心仪的主题色彩。FL Studio是一款功能强大的宿主软件,拥有强大的兼容性,强大的MIDI编辑功能和LOOP循环功能,操作页面简单直观,调取音色音源方便,适合制作Hip-hop、EDM风格的电音。FL21版本下载地址如下复制:http://t.csdn.cn/t4rXc
216 0
AI助理

你好,我是AI助理

可以解答问题、推荐解决方案等