edit/update hole without the dialog box

edit/update hole without the dialog box

shastu
Advisor Advisor
417 Views
6 Replies
Message 1 of 7

edit/update hole without the dialog box

shastu
Advisor
Advisor

Is there really no way to edit or update a hole without the dialog box opening?  I don't need to change any values at all, i just want the hole to update to the 2019 version of holes where all holes have a sketch under it.  I tried using the SilentOperation but that didn't work.  See code below:

 

Dim pdoc As PartDocument
Set pdoc = ThisApplication.ActiveDocument

Dim hFeat As HoleFeature
Set hFeat = pdoc.ComponentDefinition.Features.HoleFeatures.Item(1)

pdoc.SelectSet.Select hFeat

Dim oCntrlDefs As ControlDefinitions
Set oCntrlDefs = ThisApplication.CommandManager.ControlDefinitions

Dim oControlDef As ControlDefinition
Set oControlDef = oCntrlDefs.Item("PartNGxHoleEditCtxCmd")

ThisApplication.SilentOperation = True
oControlDef.Execute
ThisApplication.SilentOperation = False

0 Likes
418 Views
6 Replies
Replies (6)
Message 2 of 7

WCrihfield
Mentor
Mentor

I'm not familiar with the command you executed in your code. When I reverse searched it, I didn't see a DisplayName, DescriptionText, or ToolTipText  for it.  What exactly is it supposed to do?

Are you trying to create an independant sketch on the face of your part which captures the center point of the hole, then recreate the hole feature to be based on that sketch?

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 3 of 7

shastu
Advisor
Advisor

It is suppose to edit the hole and works as I want except I don't want to see the dialog box or have to hit the OK button.  I have attached a file.  If you open it, look at hole1 and notice how it doesn't have a sketch under it (created before version 2019).  Run the code and when the dialog box opens just hit the OK button and then you will notice that the hole1 now has a sketch underneath it with the appropriate dimensions on the sketch.

0 Likes
Message 4 of 7

JelteDeJong
Mentor
Mentor

Its a bit of a hack but you could send the "enter" key. try this iLogic code. it will find the holles without a sketch automaticaly.

Dim pdoc As PartDocument = ThisApplication.ActiveDocument
Dim oCntrlDefs As ControlDefinitions = ThisApplication.CommandManager.ControlDefinitions
Dim oControlDef As ControlDefinition = oCntrlDefs.Item("PartNGxHoleEditCtxCmd")
	
For Each hFeat As HoleFeature In pdoc.ComponentDefinition.Features.HoleFeatures

    If (hFeat.Sketch IsNot Nothing) Then Continue For
		
    pdoc.SelectSet.Select(hFeat)
    oControlDef.Execute()
    System.Windows.Forms.SendKeys.SendWait("{ENTER}")

Next

Jelte de Jong
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


Blog: hjalte.nl - github.com

0 Likes
Message 5 of 7

shastu
Advisor
Advisor

I really need to keep it in VBA.  I tried  the following:

 

Application.SendKeys "~",True

 

but that doesn't work.

 

 

0 Likes
Message 6 of 7

JelteDeJong
Mentor
Mentor

I dont know how to convert this to vba. Cant you use this as an external iLogic rule?

Jelte de Jong
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


Blog: hjalte.nl - github.com

0 Likes
Message 7 of 7

shastu
Advisor
Advisor

I tried it as an iLogic Rule, and it didn't work either.  I would prefer not using the sendkeys option anyway as it can be a bit risky.

0 Likes