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

Snapang within MV_blocks etc

6 REPLIES 6
Reply
Message 1 of 7
eddyrichardson
897 Views, 6 Replies

Snapang within MV_blocks etc

How do I get the angle of an Mvblock/wall or any other ADT entity to use in a lisp routine to set Snapang?

6 REPLIES 6
Message 2 of 7


@Anonymous wrote:

How do I get the angle of an Mvblock/wall or any other ADT entity to use in a lisp routine to set Snapang?


In the case of ADT Wall objects, there are several (10 ...) entries in their entity data, the last of which appears to be the endpoint as a relative location from the start point [which is the first (10 ...) entry].  So in very limited testing, this seems to work:

 

(setvar 'snapang
  (angle
    '(0 0 0)
    (cdr (assoc 10 (reverse (entget (car (entsel "\nSelect Wall object to align Snap with it: "))))))
  )
)

 

Different kinds of things are likely to have different defining characteristics, so you might need to poke around in their entity data or elsewhere to figure out how to align with them.  But for many [most?] straight things, including ADT Wall objects but also ordinary Lines and Polyline line segments and elements within Blocks and edges of Solids and Viewports and so on, you can use object snap on them with the End and Mid modes, like this:

 

(setq pickpt (entsel "\nSelect straight object to align Snap with: "))
(setvar 'snapang
  (angle
    (osnap (cadr pickpt) "_end")
    (osnap (cadr pickpt) "_mid")
  )
)

 

You can get more sophisticated with object-type restrictions, and/or variant handling depending on entity type [e.g. Xlines don't have endpoints, and Rays don't have midpoints, so they need to be treated differently].  I have something that handles those, and even aligns SNAPANG to the tangent direction at the pick point on curved objects, but it doesn't include ADT Wall objects [maybe I'll add them...].

Kent Cooper, AIA
Message 3 of 7

Thanks for that

 

are you willing to share your routine?

 

I have a lisp that is fine for lines blocks etc but would like one that I can use on all our objects in ADT.

 

I'm sure there are vlisp routines that could possibly do it but I'm and old fashioned Autolisp man....

Message 4 of 7


@Anonymous wrote:

Thanks for that

 

are you willing to share your routine?

....


Here it is, such as it is at this point.  You'll see it's full of notes to myself about options I need to choose between or improvements I'd like to make, mostly about what should be the origin for certain entity types in the set-the-Snapbase version, and aligning with nested entities.  But it should do fine for most possibilities, including some you'd probably never use [who would ever need to align the Snap angle with a Wipeout frame?].  I added ADT Wall objects to it, there are surely other things that could be added.  [You'll need to un-Zip it -- the system isn't letting me attach a .lsp file at the moment.]

Kent Cooper, AIA
Message 5 of 7
Kent1Cooper
in reply to: Kent1Cooper


@Kent1Cooper wrote:
....

....  I added ADT Wall objects to it....


Ah, but Wall objects can also be arc-shaped.  As I added them, it would work as expected on only straight ones.  If you wanted to align Snap tangent to the Wall at the selection point, the way it works for Arcs [which seems an unlikely need], I'd have to do some digging to figure out how to accomplish that.  It would be possible to at least determine whether a selected one is straight or curved [there's a Radius VLA Property, and it's 0.0 for a straight one; there's also an (assoc 40) entity data entry with the radius as for an Arc, but there are others of those, so it would take some narrowing down].

Kent Cooper, AIA
Message 6 of 7
hythamthelove
in reply to: Kent1Cooper

thank you for the reply but i think i wasn't clear enough, the problem is i have alot of texts with different orientations and i want to move all of these texts with a certain x,y displacement, but i want these displacements to be relativley to the text orientation not the global x,y system, so is there a lisp or something for this ? 

Message 7 of 7
Kent1Cooper
in reply to: hythamthelove


@hythamthelove wrote:

…. i have alot of texts with different orientations and i want to move all of these texts with a certain x,y displacement, …. relativley to the text orientation …. 


The same  X,Y displacement for all of them?  That is, would you want to be asked for the X,Y once, and to select the Text objects, and then have that same displacement [relative to each one's rotation] applied to each of them separately?

Kent Cooper, AIA

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

Post to forums  

Autodesk Design & Make Report

”Boost