本文整理汇总了Python中Base.getRealTypeAndIndex方法的典型用法代码示例。如果您正苦于以下问题:Python Base.getRealTypeAndIndex方法的具体用法?Python Base.getRealTypeAndIndex怎么用?Python Base.getRealTypeAndIndex使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Base
的用法示例。
在下文中一共展示了Base.getRealTypeAndIndex方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: getPoints
# 需要导入模块: import Base [as 别名]
# 或者: from Base import getRealTypeAndIndex [as 别名]
def getPoints(self):
view=FreeCADGui.ActiveDocument.ActiveView
objs = view.getObjectsInfo(view.getCursorPos())
obj = None
for o in objs:
if o['Object']=='ShapeModifier' or o['Object']=='ShapeMover':
obj = o
break
self.__selectedAssistantNodeName = obj['Object']
assert obj
name , idx = Base.getRealTypeAndIndex(obj['Object'])
print 'jointline modifier triggered by %s -> %d'%(name,idx)
pName , pIdx = Base.getRealTypeAndIndex(obj['Component'])
print 'jointline modifier triggered by subelement %s -> %d'%(pName,pIdx)
object = FreeCAD.getDocument(self.docName).getObject(self.objName)
subName , subIdx = Base.getRealTypeAndIndex(self.subElement)
print 'jointline modifier selected sub line %s -> %d'%(subName,subIdx)
from DDADatabase import dc_inputDatabase
from loadDataTools import DDALine
tmpLine = dc_inputDatabase.jointLines[subIdx-1]
p1 = None
p2 = None
if pIdx==2:
p1 = FreeCAD.Vector(tmpLine.startPoint)
p2 = FreeCAD.Vector(tmpLine.endPoint)
else:
# pIdx==1 maybe ShapeMover or ShapeModifier,
# but ShapeMover doesn't care about order of p1 and p2
p1 = FreeCAD.Vector(tmpLine.endPoint)
p2 = FreeCAD.Vector(tmpLine.startPoint)
return p1 , p2
示例2: finish
# 需要导入模块: import Base [as 别名]
# 或者: from Base import getRealTypeAndIndex [as 别名]
def finish(self):
if self.center:
import Base
view=FreeCADGui.ActiveDocument.ActiveView
obj = view.getObjectInfo(view.getCursorPos())
objName , objIdx = Base.getRealTypeAndIndex(obj['Object'])
assert objName == 'Block'
subName , subIdx = Base.getRealTypeAndIndex(obj['Component'])
from DDADatabase import df_inputDatabase
df_inputDatabase.blocks[subIdx-1].materialNo=11
df_inputDatabase.blocks[subIdx-1].holePointsCount+=1
# Base.__blocksMaterials__[subIdx-1] = 11 # white color, same to the background
FreeCAD.ActiveDocument.getObject('Block').ViewObject.RedrawTrigger=1 # trigger colors changes
print 'Block with hole point hided'
###############################
# temporary code , for speech
fps = df_inputDatabase.fixedPoints
if len(fps)>0:
if subIdx-1 < fps[0].blockNo:
for p in fps:
p.blockNo -=1
# tepmorary code ends
###############################
super(HolePoint,self).finish()
示例3: Activated
# 需要导入模块: import Base [as 别名]
# 或者: from Base import getRealTypeAndIndex [as 别名]
def Activated(self):
super(ShapeModifierTrigger , self).Activated()
import Base
if Base.__currentStage__ != 'DL' : # not 'DL' stage
print Base.__currentStage__
self.finish()
return
sels=FreeCADGui.Selection.getSelectionEx()
if len(sels)!=1 : # select more than 2 objects
return
s = sels[0]
count = 0
for subName in sels[0].SubElementNames:
if 'Edge' in subName : # FreeCAD may get error object selected, this code confirm the object is valid
count+=1
if count>1 :
return
if s.ObjectName=='ShapeMover' or s.ObjectName=='ShapeModifier':
return
import Base
obj = sels[0].Object
name , idx = Base.getRealTypeAndIndex(obj.Label)
print 'trigger modifier for %s --> %d'%(name , idx)
self.docName = s.DocumentName
self.objName = s.ObjectName
self.subElement = s.SubElementNames[0]
Base.__shapeBeModifying__ = [self.docName , self.objName , self.subElement]
print 'prepare done in ShapeModifierTrigger'
if name=='JointLine':
FreeCADGui.runCommand('DDA_JointLineModifier')
示例4: handleDelete
# 需要导入模块: import Base [as 别名]
# 或者: from Base import getRealTypeAndIndex [as 别名]
def handleDelete(self):
import Base
sels=FreeCADGui.Selection.getSelectionEx()
sel = sels[0]
objName = sel.ObjectName
assert len(sel.SubElementNames)==1
type , idx = Base.getRealTypeAndIndex(sel.SubElementNames[0])
database = Base.getDatabaser4CurrentStage()
database.remove(objName, [idx], args=None, ifRecord=True)
示例5: saveResult
# 需要导入模块: import Base [as 别名]
# 或者: from Base import getRealTypeAndIndex [as 别名]
def saveResult(self , p1 , p2):
obj = FreeCAD.getDocument(self.docName).getObject(self.objName)
assert obj
if not p1 or not p2:
print 'data unvalid in JointLineModifier. finishing. '
return
import Base
print 'p1 : ' , p1 , ' p2 : ', p2 , ' in JointLineModifier.finish'
objName , objNo = Base.getRealTypeAndIndex(self.objName)
subName , subIdx = Base.getRealTypeAndIndex(self.subElement)
from DDADatabase import dc_inputDatabase
from loadDataTools import DDALine
tmpLine = dc_inputDatabase.jointLines[subIdx-1]
sp = (p1[0] , p1[1] , 0)
ep = (p2[0] , p2[1] , 0)
dc_inputDatabase.changeVertices('JointLine', [subIdx-1]\
, [DDALine(sp,ep,tmpLine.materialNo)] , ifRecord=True)
self.clearAssistanceNodes()
obj.ViewObject.RedrawTrigger = True
print 'JointLineModifier save result successfully. '
示例6: getPointsAndCreateNodes
# 需要导入模块: import Base [as 别名]
# 或者: from Base import getRealTypeAndIndex [as 别名]
def getPointsAndCreateNodes(self):
import Base
sel = Base.__shapeBeModifying__
self.docName = sel[0]
self.objName = sel[1]
self.subElement = sel[2]
subName , subIdx = Base.getRealTypeAndIndex(self.subElement)
obj = FreeCAD.ActiveDocument.getObject(self.objName)
from DDADatabase import dc_inputDatabase
line = dc_inputDatabase.jointLines[subIdx-1]
p1 = line.startPoint
p2 = line.endPoint
mid = FreeCAD.Vector((p1[0]+p2[0])/2 , (p1[1]+p2[1])/2 , 0)
self.createAssistanceNodes(p1, p2, mid)