Add Fittings to Plant 3D with VBA

Add Fittings to Plant 3D with VBA

joshuaadams
Advocate Advocate
1,595 Views
4 Replies
Message 1 of 5

Add Fittings to Plant 3D with VBA

joshuaadams
Advocate
Advocate

Hi,

 

I am currently trying to add fittings to a Plant 3D drawing automatically from a database utilising VBA.

 

My current code parses commands directly to the plant 3D command line utilising the ThisDrawing.SendCommand function.

 

However, when I send the following code to plant 3D:

 

Thisdrawing.SendCommand ("_PLANTFITTINGADD " & vbCrLf), a dialog box appears as follows:

 

Plantfittingadd dialog box.jpg

 

Is there someway that I can control this dialogbox with VBA?

 

Or is there another way that I can insert fittings into my plant3D drawing through VBA that doesn't involve going through this dialogbox?

 

Thanks alot in advance for any help!!

 

- Josh

0 Likes
Accepted solutions (2)
1,596 Views
4 Replies
Replies (4)
Message 2 of 5

jabowabo
Mentor
Mentor
Accepted solution

"-PLANTFITTINGADD"

😉

Message 3 of 5

joshuaadams
Advocate
Advocate

Jabowabbo. You ma main man!

 

Worked perfectly!

 

Thanks for the help and the quick response.

0 Likes
Message 4 of 5

joshuaadams
Advocate
Advocate

Hi JaboWabbo,

 

I'm having another issue related to above that I thought you may be able to assist with. I am sending the following information to Plant3D:

 

ThisDrawing.SendCommand ("-PLANTFITTINGADD ")
SendKeys "Flange" & vbCr
SendKeys "1" & vbCr
SendKeys "50" & vbCr
SendKeys "0,0,0" & vbCr
SendKeys "0" & vbCr

 

However, I am now stuck inside the "-PLANTFITTINGADD" command. See screenshot below.

 

Plantfittingadd.png

 

I have tried using SendKeys Char(27) (the escape key) & SendKeys Char(24) (cancel) to exit me out of the command with no luck.

 

Any ideas?

 

Thanks again for your help.

 

Cheers,

 

Josh

0 Likes
Message 5 of 5

joshuaadams
Advocate
Advocate
Accepted solution

It seems I may have asked this question too soon. I've figured it out myself if anyone out there is interested. Simply add the two lines in red below to exit you out of the current command and clear the AutoCad command line.

 

doc.SendCommand ("-PLANTFITTINGADD ")

SendKeys "Flange" & vbCr
SendKeys "1" & vbCr
SendKeys "50" & vbCr
SendKeys "0,0,0" & vbCr
SendKeys "0" & vbCr
SendKeys " " 'Exits the plant fitting add command
doc.SendCommand Chr(27) & Chr(27) & Chr(27) 'Clears the command line

0 Likes