Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

ObjectDBX & Nentsel to move selected object nested in Xref

32 REPLIES 32
SOLVED
Reply
Message 1 of 33
mdhutchinson
3177 Views, 32 Replies

ObjectDBX & Nentsel to move selected object nested in Xref

Using Nentsel function, I can get info on a object that is nested with an Xref. Is there a way to move the selected object using ObjectDBX?

32 REPLIES 32
Message 2 of 33
Lee_Mac
in reply to: mdhutchinson

Yes, you could prompt the user (using either nentsel or nentselp - I explain the difference between these functions here) to select an object nested within an XRef in the active drawing, and to specify both a base point and displacement.

 

You would then use the transformation matrix & translation vector returned by nentsel/nentselp to transform the base point and displacement vector as specified by the user to be relative to the XRef reference geometry (i.e. accounting for the position, scale, rotation & orientation of the XRef).

 

You could then use ObjectDBX to interface with the XRef source drawing and perform the necessary modifications to the selected nested object (perhaps using the entity handle to reference the object to be modified).

 

My Copy to XRef program demonstrates how to perform modifications to an XRef source drawing using ObjectDBX.

Message 3 of 33
mdhutchinson
in reply to: Lee_Mac

 

looks like this might be the ticket.

 

I did find a couple issues... I had to edit the following:

 

(if (< (setq vrs (atoi (getvar 'acadver))) 20)  ; this was 16
                               "objectdbx.axdbdocument" (strcat "objectdbx.axdbdocument." (itoa vrs))

... oops... I take that back. It should have been 16 (I am on AutoCAD MEP 2013)
                           )

 

But then I got an error: Unable to interface with ObjectDBX...

I think it is erring out on this line...

 (vlax-invoke acd 'copyobjects lst (vla-get-modelspace doc))

 

I don't think copyobjects is a valid method.

 

Message 4 of 33
Lee_Mac
in reply to: mdhutchinson


@mdhutchinson wrote:

 

I had to edit the following:

 

(if (< (setq vrs (atoi (getvar 'acadver))) 20)  ; this was 16
                               "objectdbx.axdbdocument" (strcat "objectdbx.axdbdocument." (itoa vrs))
                           )

 

But then I got an error: Unable to interface with ObjectDBX...


 

You shouldn't need to change the ObjectDBX ProgID in any way; I have used that conditional statement successfully for several years without any problems.

 

Are you sure that the ObjectDBX DLL is registered on your system?

 


@mdhutchinson wrote:

 

I don't think copyobjects is a valid method.


It is.

Message 5 of 33
mdhutchinson
in reply to: Lee_Mac

yes... I see that now.

 

... control passes to your error routine on the line...

           (vlax-invoke acd 'copyobjects lst (vla-get-modelspace doc))

 

I've checked the variables... they look right to me.  See the attached image.

 

Message 6 of 33
Lee_Mac
in reply to: mdhutchinson

That's odd - what error message do you receive?

What object are you attempting to copy?

Message 7 of 33
mdhutchinson
in reply to: Lee_Mac

The msg passed to your error routine is...

    Unable to interface with ObjectDBX

 

The object is

#<VLA-OBJECT IAecMVBlockRef 0000000036507c90>

 

But it is wraped in a list... like this...

(#<VLA-OBJECT IAecMVBlockRef 0000000036507c90>)

 

I looked at the CopyObjects method... the objects to be copied should be an array of objects.  I looks like it is in a simple list... is this the case?

 

 

Message 8 of 33
Lee_Mac
in reply to: mdhutchinson


@mdhutchinson wrote:

 

The msg passed to your error routine is...

    Unable to interface with ObjectDBX


Are you sure that the above message is being passed as an argument to the *error* function?

 

The reason I ask is that this is a message that I have set to be printed to the command-line if the program cannot create an ObjectDBX Document. Though, if that is indeed the message that is printed to the command-line, the program should not be continuing beyond that point.

 

Are you using my original program, or a modified version?


@mdhutchinson wrote:
The object is

#<VLA-OBJECT IAecMVBlockRef 0000000036507c90>


I don't recognise the object name from that VLA-Object pointer - are you selecting an object native to a vertical application? Perhaps this is causing the issue, as I can only test the program using vanilla AutoCAD.


@mdhutchinson wrote:

I looked at the CopyObjects method... the objects to be copied should be an array of objects.  I looks like it is in a simple list... is this the case?


No, since I am using the vlax-invoke function to call the method which accepts arguments in native AutoLISP data types.

 

Message 9 of 33
mdhutchinson
in reply to: Lee_Mac

Yes... the object (AEC_MVBLOCK_REF, a multi-view block) is native to AutoCAD MEP - it is a Multi-View Block. (not to vanilla Autocad).

 

One dumb question... your command copies the objects selected from, and native to, the current document (drawing)... and places a copy of that object in the Xref.  Isn't this correct?

 

yes, I am using your lisp downloaded from your site...

 

I ran the routine without vlide open... this is what I got...

***************************************************************

Command: C2X

Select objects to copy to XRef:

Select xref: Enhanced reference audit problems for database "D:\Local JDriveJobs\XR-TWC-A-PLAN 1-A2.10 RoomTags.dwg" (in the form: "Name, Reason, Repair Method"): Tag Anchor [14AF], Broken reference, Release Anchor Error: AutoCAD.Application: Object was erased

********************************************************************

The mVBlock has a reference to another MEP object that is in the XRef... I think this is what is hosing it up...

I did try an ordinary circle... your lisp worked fine on this.

 

Message 10 of 33
Lee_Mac
in reply to: mdhutchinson


@mdhutchinson wrote:

 

One dumb question... your command copies the objects selected from, and native to, the current document (drawing)... and places a copy of that object in the Xref.  Isn't this correct?

 


Correct - the set of selected objects (along with any dependent objects, such as layers etc) are deep-cloned to the source drawing of the selected xref via an ObjectDBX interface, and the xref source drawing is then saved and reloaded in the active drawing before the selected objects are erased.

 


@mdhutchinson wrote:

The mVBlock has a reference to another MEP object that is in the XRef... I think this is what is hosing it up...

I did try an ordinary circle... your lisp worked fine on this.

 


Unfortunately I don't have experience working with objects native to vertical products, but I would hazard a guess that this is the source of the problem.

Message 11 of 33
mdhutchinson
in reply to: Lee_Mac

I would agree...

ANYWAY ... What I was wanting is a way to move the mvBlock that is nested within the XRef. I think a version of your lisp modified to do a move would work.

 

I've used some of your code in the past and have honored your header leaving it in place.  Might you agree to assist with a modification that would allow me to move the object that is in the Xref?

I think it might have to be a native move command.

 

(I might look at using AcCoreConsole to do this???)

Message 12 of 33
Lee_Mac
in reply to: mdhutchinson


@mdhutchinson wrote:

 

Might you agree to assist with a modification that would allow me to move the object that is in the Xref?

Your request inspired me to create a new Nested Move program - let me know what you think! Smiley Happy

Message 13 of 33
hmsilva
in reply to: Lee_Mac

Lee,

nice thinking, a very useful code!

 

Cheers

Henrique

 

off topic

 

The act of copying objects to an xref source drawing involves 

Should not be

The act of moving objects in an xref source drawing involves  Smiley Wink

EESignature

Message 14 of 33
Lee_Mac
in reply to: hmsilva


@hmsilva wrote:

Lee,

nice thinking, a very useful code!

 

Cheers

Henrique


Thank you Henrique! Smiley Happy

 


@hmsilva wrote:
The act of copying objects to an xref source drawing involves 

Should not be

The act of moving objects in an xref source drawing involves  Smiley Wink


Well spotted! - this paragraph was taken from another program description on my site involving ObjectDBX Smiley Embarassed

Message 15 of 33
Lee_Mac
in reply to: Lee_Mac

The typo should now be corrected!

Thanks again Henrique Smiley Happy

Message 16 of 33
hmsilva
in reply to: Lee_Mac

You're welcome, Lee Smiley Happy

EESignature

Message 17 of 33
kruuger
in reply to: Lee_Mac

holy cow Smiley Very Happy one of the best lisp from a long time. a lot of crazy matrix stuff.

 

i made some tesst. my comments:

- static block works fine. it would be great to move the whole object like: dimensions, block.

- select few objects at one time will be helpfull

- changes to dynamic block are only reflected to the main state of block (reset state). but in my opinion we should exclude dynamic block because chanages are not visible in bedit.

- xref work fine.

- any chance to make preview like ni express ncopy ?

 

anyway i'm "buy it" right now

waiting for rotate and removing (remove not delete) tools Smiley Wink

 

kruuger

 

 

Message 18 of 33
Lee_Mac
in reply to: kruuger


@kruuger wrote:

holy cow Smiley Very Happy one of the best lisp from a long time. a lot of crazy matrix stuff.


Cheers kruuger - that's very kind of you to say!

You know me... I love matrix maths Smiley Happy

 


@kruuger wrote:

- static block works fine. it would be great to move the whole object like: dimensions, block.


Good point - the current program is manipulating the innermost nested object which would cause problems where dimensions are concerned as the dimension would be 'dismantled'.

 

Perhaps the program should be modified to manipulate the outermost parent entity nested within the block/xref, so that the program would be manipulating dimensions/nested blocks rather than their individual components.

 


@kruuger wrote:

- select few objects at one time will be helpfull


This one would be difficult - as you know, there is no inherent AutoLISP function which permits selection of multiple nested objects. The ssget ":N" mode string is available, however, in my experience, this mode string is temperamental at best.

So a custom nested selection function would likely need to be created using a grread loop with the selection window transformed via an appropriate transformation matrix to test whether any objects within the block definition reside within the window - I believe Tim Willey attempted something similar a while back.

 


@kruuger wrote:

- changes to dynamic block are only reflected to the main state of block (reset state). but in my opinion we should exclude dynamic block because chanages are not visible in bedit.


Well spotted kruuger - indeed, after some testing, the changes are not reflected in the Block Editor, and the modifications appear to be reset upon closing the Block Editor and accepting the prompt to save any changes to the definition.

I will likely remove the compatibility with dynamic blocks from the next release of the program.

 


@kruuger wrote:

- xref work fine.


Good stuff. Smiley Wink

 


@kruuger wrote:

- any chance to make preview like in express ncopy ?


A dynamic preview would unfortunately not be possible to achieve without sacrificing all standard drawing aids (as you may be aware), since a grread loop would be required.

 

However, a selection preview would be possible by duplicating the selected nested object in modelspace (again, transformed using an appropriate matrix) and highlighting the duplicated entity.

 

This method might actually facilitate a multiple selection, since the user would receive visual feedback of the selected objects - of course, substantial error trapping would be required to account for xref-dependent items, duplicate selections, and also to ensure that all selected objects reside within the same parent entity.

 


@kruuger wrote:
waiting for rotate and removing (remove not delete) tools Smiley Wink

I'm not sure whether it would be worth investing too much time developing a range of such programs (e.g. rotate / mirror / stretch etc.), since I would be essentially recreating functionality which already exists in AutoCAD (through either the Block Editor or XOpen for xrefs).Furthermore, as stated above, I could not reproduce the visual preview of the objects being modified (as offered by the standard AutoCAD commands) without sacrificing all drawing aids, rendering the command inpractical.

 

If I'm honest, the current published program was more of an academic venture to demonstrate the various matrix transformations required to transform the displacement vector, and also how to modify an xref source drawing through an ObjectDBX interface, so I'm pleased the program is also useful as a bonus. Smiley Happy

 

 

Message 19 of 33
mdhutchinson
in reply to: Lee_Mac

Yes... very nice!  Much farther along then my effort.

Works well... however, after the first move things get kinda wacky. And the prog seems to hold objects selected somehow... move one object, then another, the first object seems be get moved also... and somehow, the distance and angle moved seems to get compounded on the second, third, and subsequent moves.

I wonder if some of the variables havn't been kept local and are somehow getting added up?

 

 

Message 20 of 33
Lee_Mac
in reply to: mdhutchinson

Thank you mdhutchinson Smiley Happy

 

The program is performing successfully in all my testing and all necessary variables have been declared local to the function - what objects are you attempt to use the program with?

 

Is anyone else experiencing the issues that mdhutchinson has described?

 

Lee

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost