Jump to content

Import DWG as lines, not symbols.


Recommended Posts

Perhaps my issue can be dealt with via Marionette but that is way beyond my ken.  

So I will ask, when importing a DWG file, is there a way to import only lines/polys?

As it is now, the import seems to convert blocks to symbols.  So I have a hundreds of symbols with gigantic lineweights. See below:1289854174_ScreenShot2021-05-06at11_00_32AM.thumb.png.85388bb56c1f31f7a951bfd3192a42c8.png

 

Each door or window, for example, is a symbol so I have to go in and edit the 2D linework to create something legible.

So I ask, is there a way to import this withy say nothing but .05 lines/polys?

 

thanks

 

bc

Link to comment

@bc That looks a lot like the old AutoCAD trick of using Pline thickness to get thick lineweights.

When I moved from AutoCAD to Vectorworks, there was a log of that in my legacy files and symbols.

 

I suspect if you look in one of those symbols, you will find that the vectorworks lineweight for the particular object is set to something big.  To resolve...

 

Use the magic wand (with the appropriate settings) to select the symbols

convert them to groups (cmd K)

ungroup them (cmd U)

and then set their lineweight to byclass in the attribute panel.

 

That would be the manual method of fixing it and akin to your desire to import blocks as just plain geometry.  I have to do this each time I import most of the work from outside architects and civil engineers.  Alternatively, you could ask them to set their pline thickness to 0 or those objects if they are keen to making your life a little easier 🙂  There is really no good reason in AutoCAD to use the pline trick since the adoption of line weights like 20 years ago.

 

edit:  Having autocad blocks imported as symbols might be a good thing for you if those symbols are repeated many times through the project.  All you have to do is go into a symbol, fix the graphics, and all the instances will update accordingly.  That might help with your doors and windows if you want to keep them as symbols instead of raw geometry.  If each symbol is unique and not repeated in the file, I would opt for my method described earlier.

Edited by jeff prince
Link to comment

This happens to me on half of the DWGs I import.  A couple years ago I got annoyed enough to make a little hacky script to stomp out crazy line weights.  It's not an example of good scripting but I use it almost every time I import a DWG 🙂 .  It works on lines inside of symbols.

 

You can change the threshold from 10 mils to whatever you need.  I haven't bothered to look up if it matters what the document line weight units are.

 

PROCEDURE Test;

VAR
LW : INTEGER;



PROCEDURE StompIt(h:HANDLE);
BEGIN
LW := GetLW(h);
IF LW >10 THEN
SetLW(h,10);
END;


BEGIN

ForEachObject(StompIt,(INSYMBOL & ((LW<>2))));

END;


RUN(Test);

 

  • Like 4
Link to comment

Scripts are resources in the resource manager.  The main difference between scripts and other resources is that scripts MUST be in folders (called palettes)

 

Copy the text from the post above.

 

In your Resource Manager > New Resource… > Script > Name the palette > Name the script > 

 

In the Script Editor window paste the above script.  Make sure the language is set to Vector Script.

 

Once it's in your Resource Manager you can right click on the folder and choose open or go to Window > Script Palettes to open the palette.  Once it's open double clicking the script in the palette will make it run.

 

Or you can right click on the script in the resource manager and choose run.

  • Like 3
Link to comment

Hey, thanks everyone!  I'll try that script, thanks michaelk.

I'll also look into the class assignment possibility mentioned by mr. troost.

@jeff prince  the problem is that every object is a separate symbol.  a 30" door here is different symbol than a 30" door over there.

  • Like 1
Link to comment

OK so I ran the script and after a bit the screen redraws and nothing seems to have changed. When I double click and edit the 2D of the symbol, I see that the linework is indeed changed and without doing anything more, I exit the symbol and the linewt changes.  So I will still have to enter each symbol individually.

Link to comment

I run the script. Less than 10 seconds passes and all of the objects blink off then on again with no visual change.  When I enter the symbol I see that it actually has changed so I exit. Voila.  But I still have to enter/exit the symbol.

 

Link to comment
2 hours ago, Jan-Burger TROOST said:

When importing you can assign line weights to classes, etc. All symbols will then remain, speeding up the file when loading/moving/editing.

Well, I couldn't find that capability in "Advanced" or anywhere during importing. But AFTER importing I selected all the classes and edited them simultaneously to the weight I wanted.  

That worked.  Thanks for that lead Jan-Burger TROOST!

Link to comment

Ha.  I just read this script.  Really clunky.  If I get a second and @PatStanford doesn't beat me to it I'll make the ForEachObject criteria be not so bad and add a reset for symbols.  It's another example of a script where the first time it did what I needed was the last time I looked at it.  I've been using it for years not realizing how clunky it is 🙂

 

Link to comment

Here's the fix that should cover the redraw:

 

PROCEDURE Test;

PROCEDURE StompIt(h:HANDLE);

	VAR
		LW : INTEGER;
        
	BEGIN
		LW := GetLW(h);
		IF LW >10 THEN SetLW(h,10);
		ResetObject(h);
	END;


BEGIN

	ForEachObject(StompIt,(INSYMBOL & ((LW<>2))));
    ReDrawAll;

END;


RUN(Test);

 

It's not all that clunky, really.  I moved the LW variable in to the StompIt procedure since you don't need it to be global, and I added some indentation to make it a hair more legible.  But the core script is about as elegant as it can be for what it does.  The only change that I would consider making would be to add in a criteria for the ForEachObject procedure to only operate on the active layer (since DWG exports tend to be on a single layer immediately following import) to remove the possibility of accidentally overwriting intentionally set high line weights (I usually have a higher line weight on my title blocks, for example), or to just set all of the flagged objects to setting the line weight to be By Class, as I think that would be more useful in the long run.  This comes with the added benefit of not needing an additional callback procedure for the ForEachObject procedure.  These changes are made below:

 

PROCEDURE Test;

VAR

	activeLayer:STRING;

BEGIN
	activeLayer:=GetLName(ActLayer);
	ForEachObject(SetLWByClass,(INSYMBOL & (L=activeLayer)));
    ReDrawAll;
END;


RUN(Test);

 

Edited by Jesse Cogswell
Removed not needed LW<>2 criteria from script.
Link to comment

I just tried removing the LW test.  In my original script -- that I've been using for years -- it let me declare a variable called LW and use the LW meaning Line Weight as part of a conditional in the criteria.  Bone headed on my part.  Can't believe that it worked at all 🙂

 

But using line weight in the criteria does an interesting thing.  It only returns objects that can have a line weight.  If you just look at objects on the layer or objects that aren't loci then it passes inappropriate objects, like symbols, to the procedure.  Better to be lucky than good.

 

Here's a new version:  

 

PROCEDURE Test;

CONST
	kLWThreshold 	= 	10;
VAR
	HLyr	: HANDLE;
	LyrNm	: STRING;

PROCEDURE StompIt(h:HANDLE);
	BEGIN
		IF GetLW(h) > kLWThreshold THEN SetLW(h,kLWThreshold);
	END;

	BEGIN
		HLyr := ActLayer;
		LyrNm := GetLName(HLyr);

		ForEachObject(StompIt,((INSYMBOL & (L=LyrNm) & (LW<>2))));
		
		ReDrawAll;
	END;


RUN(Test);

Looks like SetLW always uses Mils, no matter what the document line weight unit is.  This version will only look at the active layer.  In my quick testing it handles objects in symbols and in nested symbols!

Link to comment

If you want to play with fire, this little script will convert all the symbols in the drawing to groups.  Be real careful 🙂 

 

PROCEDURE Test;

VAR
	OK : BOOLEAN;
	
	
PROCEDURE ExplodeIt(h:HANDLE);
	BEGIN
		SymbolToGroup(h,2);
	END;


	BEGIN
		OK := YNDialog('Are you really sure you want to do this?  All symbols will be converted to groups.  Think about it.');
		IF OK THEN ForEachObject(ExplodeIt,((INSYMBOL & (T=SYMBOL))));
	END;

RUN(Test);

 

Link to comment

This last one might be the best for me because I only want the 2D and don't want any symbols OR CLASSES !

Why can't VW just bring the blocks in as groups in the first place?

Thanks for all of this everyone.

Edited by bc
Link to comment

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
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...