def Activated(self): selectedDatum = Asm4.getSelectedDatum() # check if the datum object is already mapped to something if selectedDatum.MapMode == 'Deactivated' and Asm4.checkModel(): Gui.Control.showDialog(placeDatumUI()) else: Gui.runCommand('Part_EditAttachment') '''
def Activated(self): # retrieve the Variables object self.Variables = App.ActiveDocument.getObject('Variables') # if it doesn't exist then create it (for older Asm4 documents) if not self.Variables: self.Variables = Asm4.createVariables() part = None # if an App::Part is selected: if checkPart(): part = checkPart() # if an Asm4 Model is present: elif Asm4.checkModel(): part = Asm4.checkModel() if part: part.addObject(self.Variables) #self.Variables = part.newObject('App::FeaturePython','Variables') #self.Variables.ViewObject.Proxy = Asm4.setCustomIcon(object,'Asm4_Variables.svg') # create the Variables in the document #else: #self.Variables = App.ActiveDocument.addObject('App::FeaturePython','Variables') #self.Variables.ViewObject.Proxy = Asm4.setCustomIcon(object,'Asm4_Variables.svg') # (re-)initialise the UI self.typeList.clear() self.varName.clear() self.varValue.setValue(10.0) self.description.clear() self.UI.show() # get all supported Property types for prop in self.Variables.supportedProperties(): if prop in self.allowedProperties: # remove the leading 'App::Property' for clarity self.typeList.addItem(prop[13:]) # find the Float property # propFloat = self.typeList.findText( 'App::PropertyFloat' ) propFloat = self.typeList.findText('Float') # if not found if propFloat == -1: self.typeList.setCurrentIndex(0) else: self.typeList.setCurrentIndex(propFloat) # set focus on the variable name self.varName.setFocus()
def RestoreConfiguration(docName): FCC.PrintMessage('Restoring configuration "' + docName + '"\n') doc = getConfig(docName, 'Configurations') model = Asm4.checkModel() link = Asm4.getSelectedLink() if link: RestoreObject(doc, link) else: RestoreSubObjects(doc, model) App.ActiveDocument.recompute()
def Activated(self): #global processedLinks # reset processed links cache processedLinks = [] container = Asm4.getSelectedContainer() if not container: container = Asm4.checkModel() link = Asm4.getSelectedLink() if link: showChildLCSs(link, False, processedLinks) elif container: for objName in container.getSubObjects(1): showChildLCSs(container.getSubObject(objName, 1), False, processedLinks)
def Activated(self): # This function is executed when the command is activated # initialise stuff # this is the App::Part where we'll put our App::Link self.asmPart = None self.origLink = None self.allParts = [] self.partsDoc = [] self.filterPartList.clear() self.partList.clear() self.linkNameInput.clear() # get the current active document to avoid errors if user changes tab self.activeDoc = App.ActiveDocument # an App::Part at the root of the document is selected, we insert the link there if Asm4.getSelectedRootPart(): self.asmPart = Asm4.getSelectedRootPart() # a link is selected, let's see if we can duplicate it elif Asm4.getSelectedLink(): selObj = Asm4.getSelectedLink() parent = selObj.getParentGeoFeatureGroup() # if the selectd link is in a root App::Part if parent.TypeId == 'App::Part' and parent.getParentGeoFeatureGroup( ) is None: self.asmPart = parent self.origLink = selObj elif Asm4.checkModel(): self.asmPart = self.activeDoc.getObject('Model') if self.asmPart is None: Asm4.warningBox('Please create an Assembly Model') return # Search for all App::Parts and PartDesign::Body in all open documents # Also store the document of the part for doc in App.listDocuments().values(): for obj in doc.findObjects("App::Part"): # we don't want to link to itself to the 'Model' object # other App::Part in the same document are OK # but only those at top level (not nested inside other containers) if obj != self.asmPart and obj.getParentGeoFeatureGroup( ) is None: self.allParts.append(obj) self.partsDoc.append(doc) for obj in doc.findObjects("PartDesign::Body"): # but only those at top level (not nested inside other containers) if obj.getParentGeoFeatureGroup() is None: self.allParts.append(obj) self.partsDoc.append(doc) # build the list for part in self.allParts: newItem = QtGui.QListWidgetItem() if part.Name == part.Label: partText = part.Name else: partText = part.Label + ' (' + part.Name + ')' newItem.setText(part.Document.Name + "#" + partText) newItem.setIcon(part.ViewObject.Icon) self.partList.addItem(newItem) # if an existing App::Link was selected if self.origLink: origPart = self.origLink.LinkedObject # try to find the original part of the selected link # MatchExactly, MatchContains, MatchEndsWith, MatchStartsWith ... origPartText = origPart.Document.Name + "#" + origPart.Label # if Label!=Name then the string still starts with Label partFound = self.partList.findItems(origPartText, QtCore.Qt.MatchStartsWith) if partFound: self.partList.setCurrentItem(partFound[0]) # set the proposed name to a duplicate of the original link name origName = self.origLink.Label # if the last character is a number, we increment this number lastChar = origName[-1] if lastChar.isnumeric(): rootName = origName[:-1] instanceNum = int(lastChar) while App.ActiveDocument.getObject(rootName + str(instanceNum)): instanceNum += 1 proposedLinkName = rootName + str(instanceNum) # else we append a _2 to the original name (Label) else: proposedLinkName = origName + '_2' self.linkNameInput.setText(proposedLinkName) # show the UI self.show()
def IsActive(self): # We only insert a link into an Asm4 Model if Asm4.checkModel() or Asm4.getSelectedRootPart( ) or Asm4.getSelectedLink(): return True return False
def IsActive(self): # Will handle LCSs only for the Assembly4 model #if Asm4.getSelectedLink() or Asm4.getModelSelected(): if Asm4.getSelectedLink() or Asm4.checkModel(): return True return False
def IsActive(self): # Will handle LCSs only for the Assembly4 model if Asm4.checkModel() and GetGroup('Configurations'): return True return False
def IsActive(self): # treats all container types : Body and Part if Asm4.getSelectedContainer() or Asm4.checkModel( ) or Asm4.getSelectedLink(): return True return False
def IsActive(self): if Asm4.checkModel() and getSelectionFS(): return True return False
def IsActive(self): # is there an active document ? if Asm4.checkModel() and App.ActiveDocument.getObject('Variables'): return True return False
def IsActive(self): # We only insert a link into an Asm4 Model if Asm4.checkModel(): return True return False
def IsActive(self): self.selection = getSelectedAxes() if Asm4.checkModel() and self.selection: return True return False
def IsActive(self): # if there is an Asm4 Model in the ActiveDocument, or if an App::Part is selected if Asm4.checkModel() or checkPart() or getVariables(): return True return False