Message 1 of 5
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I'm trying to create a sketch on the unfolded part, but I'm having trouble.
I'm doing this in iLogic and when I run the rule, it creates a sketch on the face of the unfolded view and creates a text box with the file name.
I need this name to be in the size 6.00mm and Font: "Txt"
This rule works on metal parts with unfolding.
Don't need cut the part, only create de sketch , and the user move to position to cut or engrave (-0,1mm).
Sub principal()
' Obter o documento ativo
Dim oPartDoc como PartDocument
oPartDoc = EsteAplicativo.DocumentoAtivo
' Verificar se o documento é uma chapa metálica
Se oPartDoc.ComponentDefinition.Type <> 150995200 Então
MessageBox.Show("O arquivo não é uma peça de chapa metálica.", "iLogic")
Sair do Sub
Fim Se
' Obter a definição da peça de chapa metálica
Dim oCompDef como SheetMetalComponentDefinition
oCompDef = oPartDoc.ComponentDefinition
' Verificar e ativar a vista planificada
Se não TypeOf ThisApplication.ActiveEditObject for FlatPattern, então
Tentar
Se oCompDef.HasFlatPattern = False Então
oCompDef.Desdobrar
Outro
oCompDef.FlatPattern.Edit
Fim Se
Pegar
MessageBox.Show("Erro ao ativar a vista planificada.", "iLogic")
Sair do Sub
Fim da tentativa
Fim Se
' Obter a vista planificada
Dim oFlatPattern como FlatPattern
oFlatPattern = EsteAplicativo.ActiveEditObject
' Obter a face do padrão planificado
Dim oFace como rosto
oFace = oFlatPattern.TopFace
' Nome do esboço e do corte
Dim sSketchName como String
Dim sTextFeatureName como string
sSketchName = "Esboço de marcação de texto"
sTextFeatureName = "Marcação de texto"
' Remover esboço existente, se houver
Dim oSketch como PlanarSketch
Para cada oSketch em oFlatPattern.Sketches
Se oSketch.Name = sSketchName Então
oSketch.Excluir
Fim Se
Próximo
' Criar um novo esboço na face planificada
oSketch = oFlatPattern.Sketches.Add(oFace, Falso)
oSketch.Nome = sSketchNome
' Obter o nome do arquivo (sem extensão)
Dim sFileName como String
sFileName = System.IO.Path.GetFileNameWithoutExtension(oPartDoc.FullFileName)
' Criar um ponto de origem para o texto
Dim oTransGeom como TransientGeometry
oTransGeom = EsteAplicativo.TransientGeometry
Dim oTextPosition como Point2d
oTextPosition = oTransGeom.CreatePoint2d(0, 0) ' Posição inicial (pode ser ajustada)
' Adicionar um texto ao esboço
Dim oTextBox como Inventor.TextBox
oTextBox = oSketch.TextBoxes.AddFitted(oTextPosition, sFileName)
' Mensagem de sucesso
MsgBox ("Marcação com o nome da peça foi adicionada!", vbInformation, "Concluído")
Fim do sub
Solved! Go to Solution.