Jump to content

lisp or other simple routine to set new hatch origin


designerstuart

Recommended Posts

trying to learn lisp..... got hundreds of objects in front of me

all need new origins for their hatch

 

anyone tell me how to write lisp that follows command:

 

-hatchedit

origin

set new origin

 

then i can just hit enter and click each one (x 100s!)

 

 

thanks

Link to comment
Share on other sites

I'd probably approach it by making a selection set of the hatches with (ssget...) then iterate through each member of the selection set using (command "-hatchedit"...) or (vlax-put-property obj 'Origin...)

 

speak up if you need more help than that

Link to comment
Share on other sites

@ rkmcswain

no, sorry more complex than that!

 

i got 100 hatches, want to individually assign (by "select new origin" clicking method) new origins for each one. i figure a routine which allows me to have a single command, then click point for each at least reduces my work by severl hundred clicks a drawing!

 

thanks keep it coming.......

Link to comment
Share on other sites

I'd probably approach it by making a selection set of the hatches with (ssget...) then iterate through each member of the selection set using (command "-hatchedit"...) or (vlax-put-property obj 'Origin...)

 

don't quite get this.... to illustrate my newbism, why does this sort of thing not work?

 

(defun c:hatcho()
command "-hatchedit" "origin" "set new origin"
)

 

a macro would also be fine.... any one-click option greatly accepted!

 

thanks

Link to comment
Share on other sites

Follow along with the exact prompts from the command.

 

eg.

Command: -HATCHEDIT

Select hatch object:
Enter hatch option [DIsassociate/Style/Properties/DRaw order/ADd 
boundaries/Remove boundaries/recreate Boundary/ASsociate/separate 
Hatches/Origin/ANnotative] <Properties>: ORIGIN

[use current origin/Set new origin/Default to boundary extents] <Default to 
boundary extents>: S

Select point:
Store as default origin? [Yes/No] <N>:

Link to comment
Share on other sites

@ alanjt thanks

 

so now i realise why mine doesn't work - i can't click mid-way through the routine i made. so now, is there a way to do this that works?

 

thanks for your prompt replies!

Link to comment
Share on other sites

@ rkmcswain

no, sorry more complex than that!

 

i got 100 hatches, want to individually assign (by "select new origin" clicking method) new origins for each one. i figure a routine which allows me to have a single command, then click point for each at least reduces my work by severl hundred clicks a drawing!

 

thanks keep it coming.......

 

Understood, but I wanted to ask since your original question was not clear.

 

i can't click mid-way through the routine i made.

Well, actually you could if you included a pause, but that defeats the purpose, since you would have to pick a point for each one.

 

It looks like to me that you would have to calculate a new origin based on the boundary of each hatch object because the 'origin' property expects a point, not a setting like "center", or "bottom left".

 

Are you wanting to set a specific point relative to each hatch object or just somewhere in the vicinity of the hatch?

Link to comment
Share on other sites

You could take the midpoint from the bounding box (vla-getboundingbox obj). Then again, you could just take one of the two bounding box points. Either could be used to change the origin point. What's the purpose of changing the origin point?

Link to comment
Share on other sites

You could take the midpoint from the bounding box (vla-getboundingbox obj). Then again, you could just take one of the two bounding box points.

 

Yea, that is what I was thinking - unless the requirement is that the origin be the "lower left" corner (or something like that...) - in which case, you would have to figure out what that point is before you could apply it.

 

What's the purpose of changing the origin point?

My guess is that maybe it's a brick/tile pattern that needs to start at a certain corner...:?:
Link to comment
Share on other sites

Yea, that is what I was thinking - unless the requirement is that the origin be the "lower left" corner (or something like that...) - in which case, you would have to figure out what that point is before you could apply it.

 

My guess is that maybe it's a brick/tile pattern that needs to start at a certain corner...:?:

Ahh, OK. The only the I ever really worry with on the origin is making sure my my concrete hatch doesn't get screwed up from being in state plane coordinates.

Link to comment
Share on other sites

My guess is that maybe it's a brick/tile pattern that needs to start at a certain corner...:?:

 

actually no it's a ceiling grid layout, but the tiles have been randomly placed and cannot be changed. my drawing has a load of new hatches, all with origin 0,0.

 

so now i have to select each one, and manually tell it where it's origin should be. this cannot be formulated, only option is to specify each with a click...... just as you mention here:

 

Well, actually you could if you included a pause, but that defeats the purpose, since you would have to pick a point for each one.

 

i think i need to include a pause, just like you say here. would it be too much trouble for someone to write out the code with this pause please?

 

to recap i think i need:

-hatchedit
origin
select new origin
<click to secify>
no

 

and i think that is all! thanks you guys for your perseverence.

Link to comment
Share on other sites

i think i need to include a pause, just like you say here. would it be too much trouble for someone to write out the code with this pause please?

 

How about something like this?

 


(defun C:NewOrg ( / ent pt1)
 (while (setq ent (car (entsel "\nSelect HATCH: ")))
   (setq pt1 (getpoint "\nSelect new Origin: "))  
   (command "._hatchedit" ent "_O" "_S" pt1 "_N")
 )  
 (princ)
)

 

Note that is very basic, no error checking, etc.

Link to comment
Share on other sites

.... and another thing ...

 

could someone please explain a bit how it works? as in, what does each line do?

i'd like to learn, if it's not a problem would be great. thanks!

 

(defun C:NewOrg ( / ent pt1)
 (while (setq ent (car (entsel "\nSelect HATCH: ")))
   (setq pt1 (getpoint "\nSelect new Origin: "))  
   (command "._hatchedit" ent "_O" "_S" pt1 "_N")
 )  
 (princ)
)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...