-AECOBJEXPLODE help

-AECOBJEXPLODE help

gccdaemon
Collaborator Collaborator
1,837 Views
14 Replies
Message 1 of 15

-AECOBJEXPLODE help

gccdaemon
Collaborator
Collaborator

Due to export to AutoCAD failing to create a file when attached x-refs have the same data referenced surface in it, I've decided to create an export routine for sending clients our files. The problem I run into is that I want to use "-aecobjexplode" in the routine, but I've noticed that it has a variant (Guessing it's multiple view related?). I need help trying to create an (if statement that determines what the variant is and chooses between the following options:

(Command "-aecobjexplode" "Y" "Y" "Y" "Y" "N" "Y")
(Command "-aecobjexplode" "Y" "A" "N" "Y" "Y" "Y" "N" "Y")

I believe that the one with the "A" shows in files that contain multiple views.

Andrew Ingram
Civil 3D x64 2019
Win 10 x64 Pro
Intel Xeon E5-1620
32 GB Ram
0 Likes
1,838 Views
14 Replies
Replies (14)
Message 2 of 15

CodeDing
Advisor
Advisor

@gccdaemon ,

 

Maybe this?

(command "-AECOBJEXPLODE" "Y") (command)
(if (wcmatch (strcase (getvar 'LASTPROMPT)) "*EXPLODE TO ANONYMOUS BLOCKS*")
  (command "-AECOBJEXPLODE" "Y" "Y" "Y" "Y" "N" "Y")
  (command "-AECOBJEXPLODE" "Y" "A" "N" "Y" "Y" "Y" "N" "Y")
);if
0 Likes
Message 3 of 15

gccdaemon
Collaborator
Collaborator

It's working for the "A" option, but not the the other. I modified it to just "*anonymous*" in case it was case sensitive, and it still didn't work. I don't think it's catching the previous prompt correctly.

Andrew Ingram
Civil 3D x64 2019
Win 10 x64 Pro
Intel Xeon E5-1620
32 GB Ram
0 Likes
Message 4 of 15

CodeDing
Advisor
Advisor

It is case sensitive, which is why I included the strcase function.

Can you post the command history when you manually run both versions of the command? That should help us greatly.

0 Likes
Message 5 of 15

gccdaemon
Collaborator
Collaborator

Command: -AECOBJEXPLODE

Explode AEC objects to primitive graphics? [Yes/No] <Yes>: Y

Explode to anonymous blocks? [Yes/No] <Yes>: A
Invalid option keyword.
; error: Function cancelled


Explode to anonymous blocks? [Yes/No] <Yes>:

Andrew Ingram
Civil 3D x64 2019
Win 10 x64 Pro
Intel Xeon E5-1620
32 GB Ram
0 Likes
Message 6 of 15

CodeDing
Advisor
Advisor

@gccdaemon ,

 

I have no problems running the code I provided. It appears to be working correctly.

How are you testing the code? Are you pasting it EXACTLY as-is into the command line (that would be incorrect)? Or are you running it inside of a function perhaps?

 

The snippet of command history that you provided tells me that ONLY the 'else' portion of the If statement is being ran.. It does not show the first line of my code being executed. If that's the case, then I am inclined to believe that one of 2 things happened:

- The code was ran incorrectly.

- The code was altered before being ran.

 

I do not say these things to try to pick on you, but merely to be very precise since we cannot get such an easy piece of code to execute. Can you share with me your EXACT process of running the code I provided?

 

Best,

~DD

0 Likes
Message 7 of 15

gccdaemon
Collaborator
Collaborator

After testing the code, yes I looked it up and started playing with it to see if I could get it to hold the anything other than a "False" flag.

 

Here is the full command line:

 

Command: (command "-AECOBJEXPLODE" "Y") Loading AEC Object Explode...
nil


Explode to anonymous blocks? [Yes/No] <Yes>: (command)
nil

Command: (if (wcmatch (strcase (getvar 'LASTPROMPT)) "*EXPLODE TO ANONYMOUS BLOCKS*")
(_> (command "-AECOBJEXPLODE" "Y" "Y" "Y" "Y" "N" "Y")
(_> (command "-AECOBJEXPLODE" "Y" "A" "N" "Y" "Y" "Y" "N" "Y")
(_> )

Invalid option keyword.
; error: Function cancelled


Explode to anonymous blocks? [Yes/No] <Yes>: *Cancel*

Andrew Ingram
Civil 3D x64 2019
Win 10 x64 Pro
Intel Xeon E5-1620
32 GB Ram
0 Likes
Message 8 of 15

CodeDing
Advisor
Advisor

It does not appear you are calling these from within a function. You are pasting them into the command line correct?

If you are testing them that way, then I would wrap them inside a (progn ... )..

BUT, try placing my code into a function first. Here, try this TEST command:

(defun c:TEST ( / )
(command "-AECOBJEXPLODE" "Y") (command)
(if (wcmatch (strcase (getvar 'LASTPROMPT)) "*EXPLODE TO ANONYMOUS BLOCKS*")
  (command "-AECOBJEXPLODE" "Y" "Y" "Y" "Y" "N" "Y")
  (command "-AECOBJEXPLODE" "Y" "A" "N" "Y" "Y" "Y" "N" "Y")
);if
(prompt "\nTEST Complete.")
(princ)
);defun

Let me know if that works.

Best,

~DD

0 Likes
Message 9 of 15

gccdaemon
Collaborator
Collaborator

I went further than that. Sorry I misunderstood your question. Yes I've tested it in a routine. Also I've tested it with:

- cmdecho on and off

- removed the "(Command)" line

- assigned "(strcase (getvar 'LASTPROMPT))" to a node and moved it all around, etc.

All with the same result.

 

(DEFUN C:DWGEXPORT (/ QAF CMDE LP)
	(vl-load-com)
;	(setq	CMDE (getvar "CMDECHO")
;		QAF (getvar 'QAFLAGS))
;	(setvar "cmdecho" 0)
	(Command	"_MODEL"
			"-VPORTS" "SI"
			"-XREF" "D" "*"
			"_UCS" "W"
			"_PLAN" "C"
			"_SNAPANG" "0")
;	(setvar "cmdecho" 1)
	(Command "-AECOBJEXPLODE" "Y")
	(Command)
	(if	(wcmatch (strcase (getvar 'LASTPROMPT)) "*EXPLODE TO ANONYMOUS BLOCKS*")
		(Command "-AECOBJEXPLODE" "Y" "Y" "Y" "Y" "N" "Y")
		(Command "-AECOBJEXPLODE" "Y" "A" "N" "Y" "Y" "Y" "N" "Y"))
;	(setvar "cmdecho" 0)
;	(IF	(setq ss (ssget "_X" '((0 . "INSERT") (2 . "`*U*"))))
;		(PROGN	(setvar 'QAFLAGS 5)
;			(Command "_.explode" ss "")
;			(setvar 'QAFLAGS QAF)))
	(Command "_AecExportToAutoCAD2010")
;	(setvar "cmdecho" CMDE)
	(Command "_CLOSE" "Y")
	(princ)
)
Andrew Ingram
Civil 3D x64 2019
Win 10 x64 Pro
Intel Xeon E5-1620
32 GB Ram
0 Likes
Message 10 of 15

CodeDing
Advisor
Advisor

@gccdaemon ,

Ok thanks for clarifying!

Hmmm.. This worked for me, does it work for you? (I have used alert yes / no to notify us)

If not, can you post an example dwg please. Probably should have started with that.

(DEFUN C:DWGEXPORT (/ QAF CMDE LP)
	(vl-load-com)
;	(setq	CMDE (getvar "CMDECHO")
;		QAF (getvar 'QAFLAGS))
	(setvar "cmdecho" 0)
;	(Command	"_MODEL"
;			"-VPORTS" "SI"
;			"-XREF" "D" "*"
;			"_UCS" "W"
;			"_PLAN" "C"
;			"_SNAPANG" "0")
	(setvar "cmdecho" 1)
	(Command "-AECOBJEXPLODE" "Y")
	(Command)
	(if	(wcmatch (strcase (getvar 'LASTPROMPT)) "*EXPLODE TO ANONYMOUS BLOCKS*")
		(alert "yes");(Command "-AECOBJEXPLODE" "Y" "Y" "Y" "Y" "N" "Y")
		(alert "no"));(Command "-AECOBJEXPLODE" "Y" "A" "N" "Y" "Y" "Y" "N" "Y"))
;	(setvar "cmdecho" 0)
;	(IF	(setq ss (ssget "_X" '((0 . "INSERT") (2 . "`*U*"))))
;		(PROGN	(setvar 'QAFLAGS 5)
;			(Command "_.explode" ss "")
;			(setvar 'QAFLAGS QAF)))
;	(Command "_AecExportToAutoCAD2010")
;	(setvar "cmdecho" CMDE)
;	(Command "_CLOSE" "Y")
	(princ)
)

 

0 Likes
Message 11 of 15

gccdaemon
Collaborator
Collaborator

Tested and both show "no". I can't upload the drawings because it's a high profile project, but I am using a storm file with pipes, surfaces and a profile and it doesn't trigger the "Views to explode [Current/All]:" option.

The other file has a road corridor, surfaces profile, and section views and DOES trigger the "Views" option.

I think that the trigger might be section views or even sample lines.

Is there a way to test for section views in a drawing?

Edit: it's not section views, could be corridor.

Andrew Ingram
Civil 3D x64 2019
Win 10 x64 Pro
Intel Xeon E5-1620
32 GB Ram
0 Likes
Message 12 of 15

CodeDing
Advisor
Advisor

My mind hurts trying to narrow this down lol. Thank you for telling me what's in the drawings though. I'll try to put some of those in and see what I come up with.

0 Likes
Message 13 of 15

Sea-Haven
Mentor
Mentor

Try this in your dwg (setq blk (tblnext "View" 1)) ; Gets the first view entry.

It returns nil for no views.

0 Likes
Message 14 of 15

CodeDing
Advisor
Advisor

@gccdaemon ,

 

I created a dwg with each one of these items (minus the intersection) and could not find a way to get the command to prompt a second question with "A" as an option. I'm not sure how to duplicate the prompt or your workflow.

image.png

 

@Sea-Haven ,

Searching the "VIEW" table was a good option, but does not trigger this prompt.

0 Likes
Message 15 of 15

gccdaemon
Collaborator
Collaborator

OK, so I don't know anything about VL, but I was thinking, would you be able to use vl-catch-all-error-p to catch an error for one of the strings? or is it too limited to catch a command based string?

Andrew Ingram
Civil 3D x64 2019
Win 10 x64 Pro
Intel Xeon E5-1620
32 GB Ram
0 Likes