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

get entity ucs

13 REPLIES 13
SOLVED
Reply
Message 1 of 14
Moshe-A
2819 Views, 13 Replies

get entity ucs

Hi Guys,

 

how can i get/set the entity ucs, the (entget) only returns 210 as extrusion direction but that's doesn't tell us the XY direction

if the ucs only rotate about the Z axis

 

i writing a command to copy (using COPY command) some texts from one ucs to current ucs and i would like the copied text to align to the current ucs

 

Thanks in Advance

Moshe

 

13 REPLIES 13
Message 2 of 14
stevor
in reply to: Moshe-A

Maybe post the results of the entget, as text or an JPG.
S
Message 3 of 14
Moshe-A
in reply to: stevor

got it, as long as the ucs is rotate about Z axis only, there is no difference in extrusion direction so it is the same as wcs

 

thank you

 

 

Message 4 of 14
Kent1Cooper
in reply to: Moshe-A


@Moshe-A wrote:

.... 

how can i get/set the entity ucs, the (entget) only returns 210 as extrusion direction but that's doesn't tell us the XY direction if the ucs only rotate about the Z axis

.... 



Once you've set the UCS to match an object, look into the values of the UCSXDIR and UCSYDIR System Variables.  Whether you can find out what they would be before changing the UCS to match, by selecting the object, probably depends on the object type.

Kent Cooper, AIA
Message 5 of 14
Lee_Mac
in reply to: Moshe-A

The X & Y directions are determined by applying the Arbitrary Axis Algorithm to the extrusion vector (normal vector); this algorithm is implemented in the AutoLISP trans function, which also accepts a normal vector argument.

 

Lee

Message 6 of 14
Moshe-A
in reply to: Lee_Mac

Lee,

 

The command i'm writting is restricted to work only on UCS that are rotated about Z axis.

i checked some objects in numerous UCS rotated about Z and all produced the same extrusion direction of (210 0.0 0.0 1.0)

 

how (trans) function would give me the right UCS XY direction?

 

could you give me an example?

 

thanks, Moshe

 

 

Message 7 of 14
Moshe-A
in reply to: Kent1Cooper

Hi Kent,

 

OK...let say i take your approch and for each text set it's UCS to current and check it's ucsXdir & ucsYdir

copy the text to a new location and get it's database list

 

(setq elist (entget (entlast)))

 

Now how can i set the object ucs in elist?

 

maybe instead of using COPY command to set the origin text UCS

and create the copied text with (entmake) would it align with the current UCS?

 

thanks, Moshe

 

 

Message 8 of 14
Lee_Mac
in reply to: Moshe-A

Moshe-A wrote:

The command i'm writting is restricted to work only on UCS that are rotated about Z axis.

i checked some objects in numerous UCS rotated about Z and all produced the same extrusion direction of (210 0.0 0.0 1.0)

 

how (trans) function would give me the right UCS XY direction?

 

could you give me an example?

 

Hi Moshe-A,

 

I think there is some confusion -

 

Planar objects (such as 2D polylines, circles, arcs etc.) define their own coordinate system known as the Object Coordinate System (OCS), whose axis vectors are calculated by applying the Arbitrary Axis Algorithm to the extrusion vector of the entity (i.e. the normal vector of the plane in which it resides). The origin of the OCS coincides with the WCS origin, and the direction of the OCS axis vectors will be unaffected by rotation of the active UCS.

 

Note that the OCS of an entity is always calculated from the extrusion vector of the entity using the method described above, and hence does not depend on the rotation or orientation of the active UCS, which is completely independent of an object.

 

To obtain the X & Y directions of the active UCS, you would need to retrieve the value of the UCSXDIR & UCSYDIR System variables, as Kent has suggested above; however, note that these are entirely independent of any objects and are only affected by the orientation of the active UCS.

 

Lee

Message 9 of 14
Moshe-A
in reply to: Lee_Mac

Lee,

 

what i meant is i want to know what was the XY direction of the ucs at the time the texts were drawn and i now understand that there is no such thing - am i right?

 

i have decided to take another approch here, instead copying each text at a time i will gather all selected objects in anonymous block and insert it align to the current ucs (and i do not mind what was the the XY direction at the time)

 

by the way about (entmake) & (entmakex) what is the difference between them?

 

i'm facing difficulties in appending a blockref with attributes to anonymous blockdef, dxf code 66 is not allowed,

have you got a workround this?

 

 

thanks,

Moshe

 

Message 10 of 14
Kent1Cooper
in reply to: Moshe-A


@Moshe-A wrote:

Hi Kent,

 

OK...let say i take your approch and for each text set it's UCS to current and check it's ucsXdir & ucsYdir

copy the text to a new location and get it's database list

 

(setq elist (entget (entlast)))

 

Now how can i set the object ucs in elist?

 

maybe instead of using COPY command to set the origin text UCS

and create the copied text with (entmake) would it align with the current UCS?

.... 


I haven't tested this [I leave that to you], but if you're talking about things rotated only about the Z axis, and want a new Text entity to have its rotation match the current UCS, I would think that you wouldn't need to check its own UCS characteristics, but regardless of what its current rotation is, could just give it a rotation angle equal to the current UCS X direction.  Either make it using (entmake) and including

 

(cons 50 (getvar 'ucsxdir))

 

in the list, or Copy one and modify the copy using something like

 

(entmod (subst (cons 50 (getvar 'ucsxdir)) (assoc 50 elist) elist))

 

or convert it to a VLA object and impose (getvar 'ucsxdir) as its Rotation property with (vlax-put... methods.

Kent Cooper, AIA
Message 11 of 14
Lee_Mac
in reply to: Moshe-A

Moshe-A wrote:

what i meant is i want to know what was the XY direction of the ucs at the time the texts were drawn and i now understand that there is no such thing - am i right?

 

Correct - this information is not stored with an entity; only the information pertaining to the properties & geometry of an entity are available in the entity DXF data, the editor configuration (UCS / Views etc.) are not recorded with the entity data.

 

Moshe-A wrote:

by the way about (entmake) & (entmakex) what is the difference between them?

 

Put simply, entmake returns the supplied DXF data if successful, whereas entmakex returns the entity name of the created entity if successful; there are other subtle differences pertaining to how objects owners are assigned, but in my experience this is rarely a significant issue.

 

Message 12 of 14
Lee_Mac
in reply to: Kent1Cooper

Kent1Cooper wrote:
Either make it using (entmake) and including

 

(cons 50 (getvar 'ucsxdir))

 

in the list, or Copy one and modify the copy using something like

 

(entmod (subst (cons 50 (getvar 'ucsxdir)) (assoc 50 elist) elist))

 

 

FYI, (getvar 'ucsxdir) will return a vector (not an angle), therefore:

 

 

(angle '(0.0 0.0) (getvar 'ucsxdir))

 

Should be used; or, to account for all UCS construction planes:

 

 

(angle '(0.0 0.0) (trans (getvar 'ucsxdir) 0 (trans '(0.0 0.0 1.0) 1 0 t) t))

 

Message 13 of 14
Kent1Cooper
in reply to: Lee_Mac


Lee_Mac wrote:

FYI, (getvar 'ucsxdir) will return a vector (not an angle), therefore:

 

(angle '(0.0 0.0) (getvar 'ucsxdir))

Should be used....


Yes, of course [shooting from the hip without actually looking at the content of the System Variable...].

Kent Cooper, AIA
Message 14 of 14
Moshe-A
in reply to: Kent1Cooper

Kent & Lee i would like to inform you that i have managed to solved this last night mainly by using (command) function i have gather all selected objects in standard block (not anonymous) and insert it as exploded at the ucsXdir angle works like a charm so thank you both for your help and advises, no dout each of you is one of the best experts here Moshe

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

Post to forums  

Autodesk Design & Make Report

”Boost